32bit vs. 64bit
Sergei Steshenko
sergstesh at yahoo.com
Sat Mar 14 22:36:59 CDT 2009
--- On Sat, 3/14/09, Jason Riedy <jason at acm.org> wrote:
> From: Jason Riedy <jason at acm.org>
> Subject: Re: 32bit vs. 64bit
> To: sergstesh at yahoo.com
> Cc: bug at octave.org
> Date: Saturday, March 14, 2009, 2:07 PM
> And Sergei Steshenko writes:
> > Well, it depends on what you're doing.
>
> Amen.
>
> Another fun example is to count how often sin(x).^2 +
> cos(x).^2
> is not 1 for a given interval. Even if sin(x) and cos(x)
> are
> correctly rounded, the result of sin(x).^2 + cos(x).^2 will
> not
> always be 1. It's easiest to see in single:
> > octave:1> x = single (0:2**-12:.5); length (x)
> > ans = 2049
> > octave:2> sum (sin (x).^2 + cos (x).^2 != 1)
> > ans = 522
>
> There is a method that gives better results in many
> situations.
> Calculate intermediate results to higher precision, and
> then
> round at points where you're storing some verifiable
> quantity.
> This was the idea behind the 80-bit x87 registers, although
> it
> was lost in the software shuffle.
>
> In the sin(x).^2 + cos(x).^2 example, computing in double
> and
> then rounding the result to single results in 1.
> > octave:3> sum (single (sin (double (x)).^2 + cos
> (double (x)).^2) != 1)
> > ans = 0
>
> So adding single-precision support to Octave was a great
> thing,
> and can produce *more* numerically sensible code. ;)
>
> Jason
And it was my point for, say, acoustics.
Input data is single precision - 32 bits; actually, input is in most cases
even 16 bit PCM from CD audio, i.e. its precision is even lower than the
one of single precision floats.
Some critical internal processing may be done using double precision, and
the output is rounded back to single precision float and maybe even to
16 bit PCM.
Regards,
Sergei.
More information about the Bug-octave
mailing list