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 › fixed point support for standard processing
Page Index Toggle Pages: 1
fixed point support for standard processing? (Read 673 times)
fixed point support for standard processing?
Oct 19th, 2007, 3:50pm
 
Is there a (simple) way to get fixed-point support in the standard processing version?
Using floating point you will run into artifacts due to loss of precision when the numbers get (very) large.
e.g.
for( int i = 0; i < 10; i++ ){
 a = sin(12.3456789 * float(i) );
 b = sin(1234567890.3456789 * float(i) );
}
In b the sine shape will vanish into a irregular block shape.

F
Re: fixed point support for standard processing?
Reply #1 - Oct 19th, 2007, 4:36pm
 
use double with Math.sin

double b;

for ( int i = 0; i < 10; i++ )
{
  b = Math.sin( 1234567890.3456789 * (double)i );
}

F
Re: fixed point support for standard processing?
Reply #2 - Oct 19th, 2007, 5:50pm
 
that helps too.
thanks!
Page Index Toggle Pages: 1