[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-users] (no subject)



Hi

I am trying to create iterative process but the process keeps producing "inf" and then "nan" due to the precision of the floating point number. I have tried trunc and round and both do not seem to work.

Any thoughts would be greatly appreciated?!

Thanks

(
	/* constants */
	var a = 10.0;
	var b = 28.0;
	var c = -8.0/3.0;
	
	/* variables */
	var count = 1;
	var i = 20;
	var x = 0.001;
	var y = 0.001;
	var z = 0.001;

	/* iterate */
	while (
			{
				count <= i
			 },
			{
				/* formula */
				x = a*(y-x);
				y = (b*x)-y-(x*z);
				z = (c*z)+(x*y);
								
				x = x.trunc(0.001);
				y = y.trunc(0.001);
				z = z.trunc(0.001);
				
				/* standard output */
				(""+count+"x:"+x).postln;
				(""+count+"y:"+y).postln;
				(""+count+"z:"+z).postln;
				
				count = count + 1;
			}
	);
)