Glenn, base2 floating point math, the 'normal' base2 fp math we
computer people use, and decimal floating point math, have different
audiences: normal floating point math is used for normal
computer-related tasks, including hpc, admin work and so on, and
decimal floating point math is used where human issues are involved,
like monetary calculations or database/spreadsheet math where the
base2 vs base10 rounding errors are not acceptable.

The pain with _Decimal32, _Decimal64 and _Decimal128 as proposed for
the next ISO C standard is that the current Linux/gcc implementation
works good, except that I/O via glibc stdio is not implemented, i.e.
printf and scanf do not work, because the maintainers, including
Ulrich Drepper, appear to wait, until it decimal floating point
becomes part of the ISO C standard.
The fortunate thing with ast is that it doesn't have that kind of
problem, because it has it's own stdio, and the existing base2 code in
ast can be adopted with little work to handle the extra three data
types (_Decimal32, _Decimal64, _Decimal128).

Olga

On Fri, Feb 8, 2013 at 4:04 PM, Glenn Fowler <[email protected]> wrote:
>
> the limit here is encased in LDBL_DIG
> "Number of significant digits in a" long double "floating point number."
> (because ksh uses long double for floating point arith)
>
> if a chunk of long double arith code, C, ksh or otherwise arrives at a
> comparison of two numbers from two different routes and demands significance
> beyond LDBL_DIG (or possibly less than LDBL_DIG if there is enough roundoff 
> error)
> the the comparison will fail in the roundoff noise
>
> in the example posted the roundoff error was well into the area beyond 
> LDBL_DIG
>
> so rather than cataloging implementations of math functions that could vary 
> from
> compiler to compiler on the same machine it would be much easier to code with
> LDBL_DIG in mind
>
> there are two other other mechanisms recently added to C:
>
> a common area for roundoff error is in string <=> long double conversion
> interpreters are especially hit in this area
> coding with hex floating point notation for constants helps here
> the constant syntax is 0x...p... and the corresponding printf format is %a
> this is implemented in ast (and thus ksh)
>
> there is also a decimal floating point api
> we have some of the details from Roland Mainz
> this is not implemented yet
>
> On Fri, 8 Feb 2013 09:35:46 +0100 Lionel Cons wrote:
>> Forwarding Icarus's comment.
>
>> What we're facing here seems that different implementations of a libm
>> function may result different results at the last digits, right? Is
>> there a function to test how accurate the libm functions are, and is
>> there a libm function which tests for equality in a specified
>> precision?
>
>> Lionel
>
>> ---------- Forwarded message ----------
>> From: Icarus Sparry <[email protected]>
>> Date: 31 January 2013 05:29
>> Subject: Re: [ast-users] Floating point oddities with pow()? Accuracy 
>> problem?
>> To: Lionel Cons <[email protected]>
>
>> pow(x, y) is typically implemented as exp(y * ln(x))
>
>> On Jan 30, 2013 8:24 PM, "Lionel Cons" <[email protected]> wrote:
>> >
>> > On 29 January 2013 10:50, Lionel Cons <[email protected]> 
>> > wrote:
>> > > Can someone explain why the the examples below yield a difference? IMO
>> > > pow() should deliver the same result as a x*x*x*... sequence. Or not?
>> > >
>> > > ksh -c 'float x y ; ((x=y=.1 , y=pow(y,4.) , x=x*x*x*x)) ; printf
>> > > "%30.30f\n" x-y'
>> > > -0.000000000000000000000006617444
>> > > ksh -c 'float x y ; ((x=y=.1 , y=pow(y,6.) , x=x*x*x*x*x*x)) ; printf
>> > > "%30.30f\n" x-y'
>> > > -0.000000000000000000000000103397
>> > > ksh -c 'float x y ; ((x=y=.1 , y=pow(y,8.) , x=x*x*x*x*x*x*x*x)) ;
>> > > printf "%30.30f\n" x-y'
>> > > -0.000000000000000000000000001615
>> > >
>> > > Platform is Suse 12.1 on AMD64.
>> >
>> > The difference between pow() and manual multiplication (example below)
>> > revolves around certain values. Does that ring a bell?
>> >
>> > ksh -c 'float x y i ; for ((i=-5 ; i < 5 ; i=i+.1)) ; do ((x=y=.1*i ,
>> > y=pow(y,8) , x=x*x*x*x*x*x*x*x)) ; printf "%30.30f\n" x-y ; done'
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000211758236
>> > -0.000000000000000000000423516473
>> > 0.000000000000000000000211758236
>> > 0.000000000000000000000105879118
>> > 0.000000000000000000000105879118
>> > -0.000000000000000000000105879118
>> > -0.000000000000000000000211758236
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000052939559
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000052939559
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000013234889
>> > 0.000000000000000000000013234889
>> > 0.000000000000000000000013234889
>> > -0.000000000000000000000019852334
>> > 0.000000000000000000000006617444
>> > 0.000000000000000000000006617444
>> > 0.000000000000000000000003308722
>> > 0.000000000000000000000006617444
>> > 0.000000000000000000000006617444
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000827180
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000620385
>> > -0.000000000000000000000000206795
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000000206795
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000000051698
>> > -0.000000000000000000000000012924
>> > -0.000000000000000000000000006462
>> > -0.000000000000000000000000006462
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000000000807
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000012
>> > -0.000000000000000000000000000003
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000000000003
>> > -0.000000000000000000000000000012
>> > 0.000000000000000000000000000151
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000000000807
>> > 0.000000000000000000000000001615
>> > 0.000000000000000000000000006462
>> > 0.000000000000000000000000012924
>> > -0.000000000000000000000000012924
>> > -0.000000000000000000000000025849
>> > -0.000000000000000000000000051698
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000103397
>> > 0.000000000000000000000000103397
>> > -0.000000000000000000000000413590
>> > -0.000000000000000000000000413590
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000001654361
>> > 0.000000000000000000000003308722
>> > 0.000000000000000000000006617444
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000006617444
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000013234889
>> > -0.000000000000000000000026469779
>> > -0.000000000000000000000026469779
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000026469779
>> > 0.000000000000000000000052939559
>> > 0.000000000000000000000052939559
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000052939559
>> > -0.000000000000000000000052939559
>> > -0.000000000000000000000105879118
>> > -0.000000000000000000000317637355
>> > 0.000000000000000000000000000000
>> > -0.000000000000000000000211758236
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000000000000
>> > 0.000000000000000000000423516473
>> > 0.000000000000000000000000000000
>> >
>> > Lionel
>> > _______________________________________________
>> > ast-users mailing list
>> > [email protected]
>> > http://lists.research.att.com/mailman/listinfo/ast-users
>
>> --
>> Lionel
>> _______________________________________________
>> ast-users mailing list
>> [email protected]
>> http://lists.research.att.com/mailman/listinfo/ast-users
>
> _______________________________________________
> ast-developers mailing list
> [email protected]
> http://lists.research.att.com/mailman/listinfo/ast-developers



-- 
      ,   _                                    _   ,
     { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
.----'-/`-/     [email protected]   \-`\-'----.
 `'-..-| /       http://twitter.com/fleyta     \ |-..-'`
      /\/\     Solaris/BSD//C/C++ programmer   /\/\
      `--`                                      `--`
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users

Reply via email to