From: "Ondřej Bílka" Date: 2011-11-08T16:22:23+09:00 Subject: [ruby-core:40833] Re: [ruby-trunk - Bug #5497] Math.log10(10_000) error on HP-UX/PA Not a bug just another example of inprecision of floats. On Sat, Oct 29, 2011 at 03:26:41PM +0900, The Written Word Inc wrote: > > Issue #5497 has been updated by The Written Word Inc. > > > Yui NARUSE wrote: > > The Written Word Inc wrote: > > > (ia64) > > > p Math.log10(10_000) > > > 4 > > > > Show the result of `p 4.0`. > > (ia64) > p 4.0 > 4.0 > (pa-risc) > p 4.0 > 4.0 > > > > (pa-risc) > > > p Math.log10(10_000) > > > 3.9999999999999996 > > > > Build and run following C code: > > > > % cat f.c > > #include > > #include > > > > int main(void) { > > printf("%a\n", log10(10000)); > > return 0; > > } > > % gcc -lm f.c && ./a.out > > 0x1p+2 (or something) > > $ cat t.c > #include > #include > > int main(void) { > printf("%f\n", log10(10000)); > printf("%a\n", log10(10000)); > return 0; > } > > (ia64) > $ cc +O1 +Ofltacc +Olit=all +Oentrysched +Odataprefetch -lm t.c > $ ./a.out > 4.000000 > 0x1.0000000000000p+2 > > %a is only supported on HP-UX/IA systems, not HP-UX/PA. We're using the HP-UX C compiler to build Ruby as well. > ---------------------------------------- > Bug #5497: Math.log10(10_000) error on HP-UX/PA > http://redmine.ruby-lang.org/issues/5497 > > Author: The Written Word Inc > Status: Open > Priority: Normal > Assignee: > Category: core > Target version: 1.9.2 > ruby -v: UNKNOWN > > > I've built 1.9.2 from svn revision at 33531 on HP-UX/PA and HP-UX/IA. I'm getting two different results for Math.log10(10_000) depending on IA64 and PA-RISC: > (ia64) > p Math.log10(10_000) > 4 > (pa-risc) > p Math.log10(10_000) > 3.9999999999999996 > > Any idea where in the code I can look to try and fix this? > > > -- > http://redmine.ruby-lang.org -- loop found in loop in redundant loopback