+ 7
Why (1/3 + 1/3 + 1/3 == 1) is False?
8 Respuestas
+ 17
Because 1/3 goes on to infinity. Since the compiler can't handle infinite numbers, it rounds it after some decimal points after the comma.
So 1/3 + 1/3 + 1/3 will equal 0.999999999 or something like that, but not one because of the limitations of the compiler
! (1/3 equals 0.333... and not 0) !
+ 20
//in java
1/3 means 0
System.out.print(1/3); //0
+ 10
because 1/3 is 0 and so on 0 + 0 + 0 = 0 which is different from 1
+ 7
yes, that is true on floats and doubles, but these are integers so 1/3 = 0
+ 5
@Vukan That highly depends on the language in question.
+ 2
You would need to round the 0.99999. If it's in js you could use something like Math.floor, Math.ceil, or Math.round.
I think.toFixed(); can round sometimes as well, but it would still show decimal places
+ 1
@Full Gamer: 0.999... is equal to 1 in pure math. There is no number in between.
/math teacher off
+ 1
Thank you guys, this has bent the laws of maths. Appreciate it.