Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
woberndt
woberndt's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
float inaccuracy?
[2 Replies]
27-Feb-2011 04:36 AM
Forum:
General Discussion
Hi there.
Adding a float value n times gives a different result than multiplying it by n. Can anyone help me with this difference?
int ct = 100000;
float sum=0.0;
for (int i=0; i<ct; i++) {
sum += 255.0;
}
println (nfc (sum,0));
// prints 25.534.204
sum = ct * 255.0;
println (nfc (sum,0));
// prints 25.500.000
«Prev
Next »
Moderate user : woberndt
Forum