Bug 652 : long n=30; print(n) >> 30.0
Last modified: 2007-10-21 22:43




Status:
RESOLVED
Resolution:
WONTFIX -
Priority:
P2
Severity:
normal

 

Reporter:
alphachapmtl
Assigned To:
fry

Attachment Type Created Size Actions

Description:   Opened: 2007-10-20 23:47
A long value prints with a decimal point (version 0129, Windows XP Pro)

void setup() {
size(100,100);
noLoop();
}

void draw() {
//
int a=30;
println(a); // >> 30
println(str(a)); // >> 30
println(a+""); // >> 30
//
long b=30;
println(b); // >> 30.0
println(str(b)); // >> 30.0
println(b+""); // >> 30
}
Additional Comment #1 From fry 2007-10-21 06:38
hm, we don't actually support longs or doubles anywhere in the api.. but
print() and println() are pretty basic so i'll just add a long/double
version for them for 0131.
Additional Comment #2 From fry 2007-10-21 14:00
on second thought, this is a bad idea. it might be useful for println(),
it's impossible to draw the line (do we support long(), double(), str()?
what else?)

so if you're printing longs and doubles, use System.out.println() instead.

it's printing as a float because apparently a long will cast itself as a
float, and a float version of println() does exist.
Additional Comment #3 From alphachapmtl 2007-10-21 22:43
(In reply to comment #2)
.. so if you're printing longs and doubles, use System.out.println() instead ..

Yes, that will do. That's a good simple solution.