LocalDateTime.now() has different levels of precision on Windows and Mac machine

The precision is different because LocalDateTime.now() uses a system default Clock. Obtains the current date-time from the system clock in the default time-zone. This will query the system clock in the default time-zone to obtain the current date-time. … The link in this Javadoc takes you to Clock.systemDefaultZone() which states (emphasis mine): Obtains a clock … Read more

How to Java String.format with a variable precision?

You sort of answered your own question – build your format string dynamically… valid format strings follow the conventions outlined here: http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html#syntax. If you want a formatted decimal that occupies 8 total characters (including the decimal point) and you wanted 4 digits after the decimal point, your format string should look like “%8.4f”… To my … Read more

C# Converting 20 digit precision double to string and back again

Use the “R” numeric format string: double d = 0.00034101243963859839; string s = d.ToString(“R”); //… double d2 = double.Parse(s); if(d == d2) { //– Success } The R stands for “round-trip”. From the linked document: This format is supported only for the Single and Double types. The round-trip specifier guarantees that a numeric value converted … Read more

Python numpy float16 datatype operations, and float8?

To the first question: there’s no hardware support for float16 on a typical processor (at least outside the GPU). NumPy does exactly what you suggest: convert the float16 operands to float32, perform the scalar operation on the float32 values, then round the float32 result back to float16. It can be proved that the results are … Read more

Golang floating point precision float32 vs float64

Using math.Float32bits and math.Float64bits, you can see how Go represents the different decimal values as a IEEE 754 binary value: Playground: https://play.golang.org/p/ZqzdCZLfvC Result: float32(0.1): 00111101110011001100110011001101 float32(0.2): 00111110010011001100110011001101 float32(0.3): 00111110100110011001100110011010 float64(0.1): 0011111110111001100110011001100110011001100110011001100110011010 float64(0.2): 0011111111001001100110011001100110011001100110011001100110011010 float64(0.3): 0011111111010011001100110011001100110011001100110011001100110011 If you convert these binary representation to decimal values and do your loop, you can see that for float32, the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)