We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › println(50%76800); = 50, why not 38400
Page Index Toggle Pages: 1
println(50%76800); = 50, why not 38400 (Read 413 times)
println(50%76800); = 50, why not 38400
May 13th, 2009, 12:27pm
 
println(50%76800);

prints 50 to the console, I'm expecting 38400, why doesn't it do that?
And how can I solve it?
Re: println(50%76800); = 50, why not 38400
Reply #1 - May 13th, 2009, 12:43pm
 
Can you explain why you're expecting 38400?

The "%" sign performs a modulo operation which returns what would be the remainder of a division. (Look up modulo on Wikipedia if you have questions.) 50 / 76800 = 0R50, so the modulo will return 50.
Re: println(50%76800); = 50, why not 38400
Reply #2 - May 13th, 2009, 12:45pm
 
Oh, I think I see now what you're trying to do. Fifty percent of 76800, yes? Try converting the percentage to a decimal and multiplying.

50% of 76800 becomes 0.5 * 76800, which will give you 38400.
Re: println(50%76800); = 50, why not 38400
Reply #3 - May 13th, 2009, 12:49pm
 
yes your second post  Smiley

thx
Page Index Toggle Pages: 1