FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Bugs
   Software Bugs
(Moderator: fry)
   text(data,x,y) corrupts 'data'
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: text(data,x,y) corrupts 'data'  (Read 646 times)
Florito

WWW Email
text(data,x,y) corrupts 'data'
« on: Jan 19th, 2005, 11:59am »

When trying to put numbers on screen using the text(data,x,y) function, the numbers get corrupted.
 
Example:
text(54321.812,x,y) will put '54321.8125' on screen.
text(7654321.812,x,y) will put '7654322.000' on screen.
 
Here the code that generated this example:
------------------------------------------------------------------------ -----------
BFont MBold; MBold=loadFont("Meta-Bold.vlw.gz"); textFont(MBold,20);
size(400,300);
text("displaying 54321.812:",6,20);  text(54321.812,220,20);
text("displaying 7654321.812:",6,40);  text(7654321.812,220,40);
text("displaying blub 654321.812:",6,60);  text("blub "+654321.812,220,60);
------------------------------------------------------------------------ -----------
 
I am using processing-0068 on a windows xp machine.
 
Florito [http://www.florito.net]
 
toxi

WWW
Re: text(data,x,y) corrupts 'data'
« Reply #1 on: Jan 19th, 2005, 12:17pm »

as so often the reason for odd behaviour lies somewhere else - this is not a bug as such but a precision issue with large floats:
 
Code:
float b=7654321.812;
println(b);
 
// outputs: 7654322.0

 
more info can be found here:
 
What's so special about 2097152.0
Using floats versus casting to floats
 

http://toxi.co.uk/
Pages: 1 

« Previous topic | Next topic »