This site requires JavaScript, please enable it in your browser!
Greenfoot back
mal
mal wrote ...

2011/10/13

Declaring Long problem

mal mal

2011/10/13

#
Hi There, I'm trying to declare a long in my application. like this: public long a = 0.6; but I get an error saying it's expecting a long but I put a double, so I try this: public long a = 0.6L; but now Greenfoot is telling me I need ";" before the L. What am I doing wrong? Also, is this statement valid: if(long > double) { do stuff } or does it need to be : if(long > long) { do stuff } Thanks.
davmac davmac

2011/10/13

#
A "long" is a long integer - a whole number, without a decimal point. Perhaps you wanted "double"? eg: public double a = 0.6; Regarding comparisons, it is fine to compare a long value with a double value - I think that's what you're asking?
mal mal

2011/10/13

#
Thanks Davemac, As soon as I posted that I realized my mistake! Silly error!! My brain said "as you're dealing with fractions of a second, you need to say "a = 0.6" as opposed to "a = 600". All good now though, thanks for your help. Paul.
You need to login to post a reply.