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 › dumb datatype casting question
Page Index Toggle Pages: 1
dumb datatype casting question (Read 654 times)
dumb datatype casting question
Jul 22nd, 2005, 6:57am
 
Hello all

I guess the hot summer breeze rusted my brain, but I'm not being able to convert a double into a float;
the float() casting does not work with double values;
what should I do?

thanks!

*edit*

ok, I got this
Quote:
double test = 1.2345678901234567890;
float f = new Double(test).floatValue();
println(f);


but is there an easier way? Do I have to create a Double object like that?

Thanks again!
Re: dumb datatype casting question
Reply #1 - Jul 22nd, 2005, 10:34am
 



Code:

double test = 1.2345678901234567890;
float test1 = (float)test;

println(test1);


Seems fine to me.
Re: dumb datatype casting question
Reply #2 - Jul 22nd, 2005, 3:32pm
 

yep, you're right. I was using this sintax, that didn't work...

double i = 65.2342342342345;
float f = float(i);
println(i + " : " + f);
Page Index Toggle Pages: 1