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.
Page Index Toggle Pages: 1
decimal (Read 397 times)
decimal
Jul 3rd, 2006, 11:26pm
 
I am trying to take an integer say 5.837974395038730 and seperate this number in two parts. I am trying to get it so that the 5 is stored in one variable and every thing after the decimal is in another.  I tried using the % command and it was working out for a while but now my needs have changed and I can't think of a way to do this. any ideas would be great.
Re: decimal
Reply #1 - Jul 4th, 2006, 8:54am
 
That's your variable with the decimal number :
float a = 5.837974395038730;

Here you get the integer part :
int b = floor(a);

And here the decimal part :
float c = a - b;
Page Index Toggle Pages: 1