System.out.println(2.14656);
2.14656
System.out.println(2.14656%2);
+0.14656000000000002
WTF?
They give the expected results. Your expectations are wrong.
When you enter a double-precision literal 2.14656, what you actually get is the closest double-precision value, which:
2.14656000000000002359001882723532617092132568359375
println happens around this when it prints it (up to 17 significant digits), so you see the nice value that you expect.
println
After the operation of the module (which is accurate), the value:
0.14656000000000002359001882723532617092132568359375
, , , - , , , , 2.
2
base-2 -10.
"" - 2, 4, 8, 16, 32, 64 .. , 10, 100, 1000, 10000 - "" -10.
. , 1.42E-13 2.11E47. "" -10. .
, . 100% , . , 100%. , int. , , , , .
, , , . , , 1/100, 1/32 1/20 .., . , , . -, , .
http://en.wikipedia.org/wiki/Round-off_error#Representation_error
Source: https://habr.com/ru/post/1768662/More articles:ΠΡΡΡ Π»ΠΈ ΡΠ²ΠΎΠ±ΠΎΠ΄Π½ΡΠ΅ ΡΠΌΠ΅ΡΠ½ΡΠ΅ ΡΠ°ΠΌΠΊΠΈ, ΠΊΠΎΡΠΎΡΡΠ΅ ΠΌΠΎΠ³ΡΡ ΠΈΠ·Π΄Π΅Π²Π°ΡΡΡΡ Π½Π°Π΄ ΠΌΠ΅ΡΠΎΠ΄Π°ΠΌΠΈ ΠΈ ΠΊΠ»Π°ΡΡΠ°ΠΌΠΈ, ΠΊΠΎΡΠΎΡΡΠ΅ Π½Π΅ ΡΠ²Π»ΡΡΡΡΡ Π²ΠΈΡΡΡΠ°Π»ΡΠ½ΡΠΌΠΈ, ΡΡΠ°ΡΠΈΡΠ΅ΡΠΊΠΈΠΌΠΈ ΠΈΠ»ΠΈ Π³Π΅ΡΠΌΠ΅ΡΠΈΡΠ½ΡΠΌΠΈ? - .netEfficiency Parcelable for communication inproc - androidBasic authentication in Glassfish - securityΠ ΡΠ°ΠΌΠΊΠ°Ρ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ Π»ΡΡΡΠΈΠΉ ΡΠΏΠΎΡΠΎΠ± ΠΏΠ΅ΡΠ΅Π΄Π°ΡΠΈ ΠΏΠΎΠ»ΡΠ·ΠΎΠ²Π°ΡΠ΅Π»ΡΡΠΊΠΈΡ ΠΎΠ±ΡΠ΅ΠΊΡΠΎΠ² ΠΌΠ΅ΠΆΠ΄Ρ Π΄Π΅ΠΉΡΡΠ²ΠΈΡΠΌΠΈ? - androidIs there a hook available when creating a tag in Subversion? - svnhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1768663/batch-xcopy-all-files-to-folder-with-loop&usg=ALkJrhiHi5uZccEXDX3srYKuOlo44de5rQbest jquery-based lightbox / popup dialogbox? - jqueryHas anyone accidentally seen the maven archetype for the Grails + GWT project? - mavenDevelopment for 64-bit and 32-bit - installerWhy Perl sysopen reports success, but $! is there a mistake? - perlAll Articles