Re: M_PIl
Using a bignum library like GMP ( http://gmplib.org/ ) might be a good idea when precision is that important. Jelle On 09/02/2012 02:35 AM, Pierre Abbat wrote: On Friday, August 31, 2012 18:33:36 Jelle Hermsen wrote: Personally I just define pi with 4*atan(1). Is there a good reason to use M_PI1 instead? I defined M_PIl as (4*atan(1.)) and ran the program. It gave the same result as defining M_PIl as M_PI. The reason for using M_PIl is that it's a ten-byte float, so multiplying by it will result in better accuracy than multiplying by M_PI, which is an eight-byte float. I once wrote a Mandelbrot/Julia program that gave wrong results; it was continuing the iteration instead of stopping when it saw a previously seen value. I submitted a bug to the GCC authors. It turned out to be not a bug in the compiler. The program was comparing a just-computed point, expressed as a ten-byte float in the processor, with a previously computed point, expressed as an eight-byte float in a double variable, and they were not equal. Pierre
Re: M_PIl
On Monday, September 03, 2012 11:15:02 Jelle Hermsen wrote: Using a bignum library like GMP ( http://gmplib.org/ ) might be a good idea when precision is that important. This program doesn't use or need bignums, and GMP has neither infinity nor NaN nor trig functions. Pierre -- .i toljundi do .ibabo mi'afra tu'a do .ibabo damba do .ibabo do jinga .icu'u la ma'atman.
Re: M_PIl
On Friday, August 31, 2012 18:33:36 Jelle Hermsen wrote: Personally I just define pi with 4*atan(1). Is there a good reason to use M_PI1 instead? I defined M_PIl as (4*atan(1.)) and ran the program. It gave the same result as defining M_PIl as M_PI. The reason for using M_PIl is that it's a ten-byte float, so multiplying by it will result in better accuracy than multiplying by M_PI, which is an eight-byte float. I once wrote a Mandelbrot/Julia program that gave wrong results; it was continuing the iteration instead of stopping when it saw a previously seen value. I submitted a bug to the GCC authors. It turned out to be not a bug in the compiler. The program was comparing a just-computed point, expressed as a ten-byte float in the processor, with a previously computed point, expressed as an eight-byte float in a double variable, and they were not equal. Pierre -- The Black Garden on the Mountain is not on the Black Mountain.
M_PIl
I'm developing a program which represents angles internally as binary fractions (0x8000 means 360°). To convert the angle to radians, I used M_PI originally, felt I needed more accuracy, and found that Linux has M_PIl, which has a few extra digits so that it is accurate as a ten-byte float (the processor's internal representation). DFBSD doesn't have M_PIl, so I wrote a preprocessor directive which uses M_PI if M_PIl doesn't exist. I run a test which adds sin 45° to sin 225° and such combinations around the circle, squares the errors, and adds them up. printf(total sine error=%e\n,totsinerror); printf(total cosine error=%e\n,totcoserror); printf(total cis error=%e\n,totciserror); assert(totsinerror+totcoserror+totciserror1e-29); //On Linux, the total error is 6e-39 and the M_PIl makes a big difference. //On DragonFly BSD, the total error is 5e-30 and M_PIl is absent. Pierre -- When a barnacle settles down, its brain disintegrates. Já não percebe nada, já não percebe nada.
Re: M_PIl
Personally I just define pi with 4*atan(1). Is there a good reason to use M_PI1 instead? Cheers, Jelle --Original Message-- From: Pierre Abbat Sender: users-err...@crater.dragonflybsd.org To: users@crater.dragonflybsd.org Subject: M_PIl Sent: Aug 31, 2012 19:52 I'm developing a program which represents angles internally as binary fractions (0x8000 means 360°). To convert the angle to radians, I used M_PI originally, felt I needed more accuracy, and found that Linux has M_PIl, which has a few extra digits so that it is accurate as a ten-byte float (the processor's internal representation). DFBSD doesn't have M_PIl, so I wrote a preprocessor directive which uses M_PI if M_PIl doesn't exist. I run a test which adds sin 45° to sin 225° and such combinations around the circle, squares the errors, and adds them up. printf(total sine error=%e\n,totsinerror); printf(total cosine error=%e\n,totcoserror); printf(total cis error=%e\n,totciserror); assert(totsinerror+totcoserror+totciserror1e-29); //On Linux, the total error is 6e-39 and the M_PIl makes a big difference. //On DragonFly BSD, the total error is 5e-30 and M_PIl is absent. Pierre -- When a barnacle settles down, its brain disintegrates. Já não percebe nada, já não percebe nada.