We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm unconventionally navigating a 2-d array by adding.2 to an arbitrary variable. it cut down on a lot of code and worked really well until right after 4.6... also I made a small example of a for loop adding the same way... it produces the same result.
float hi=0;
for (int i=0;i<25;i++) {
hi+=.2;
println(hi);
}
these are the last 3 sets of println()'s it's working
4.6
[0] -1
[1] 0
[2] 649
[3] 382
[4] 649
[5] 382
lines omitted
[4] 649
[5] 382
[6] 649
[7] 382
[8] 649
[9] 383
[0] 649
[1] 383
[2] 649
[3] 383
[4] 649
[5] 383
[6] -50
[7] -50
[8] -50
[9] -50
it's working
4.7999997
[0] -1
[1] 0
[2] 649
[3] 382
[4] 649
[5] 382
lines omitted
[0] 649
[1] 383
[2] 649
[3] 383
[4] 649
[5] 649
[6] 383
[7] -50
[8] -50
[9] -50
it's working
4.9999995
[0] -1
[1] 0
[2] 649
[3] 382
[4] 649
[5] 382
[6] 649
lines omitted
[9] 383
[0] 649
[1] 383
[2] 649
[3] 383
[4] 649
[5] 649<-------- problem arises here
[6] 383
[7] 649
[8] 383
[9] -50
java.lang.NullPointerException
at processing.mode.java.runner.Runner.findException(Runner.java:926)
at processing.mode.java.runner.Runner.reportException(Runner.java:871)
at processing.mode.java.runner.Runner.exceptionEvent(Runner.java:797)
at processing.mode.java.runner.Runner$2.run(Runner.java:686)
Answers
Read reference about primitive type
float
:http://processing.org/reference/float.html
Thanks. That was what I figured it was :P.
Required reading: What Every Computer Scientist Should Know About Floating-Point Arithmetic