syphilis has asked for the wisdom of the Perl Monks concerning the following question:
That script does pretty much what I want. On a perl built without long double support it simply prints out:use warnings; use strict; use Inline C => Config => BUILD_NOISY => 1; use Inline C => <<'EOC'; SV * foo(SV * nv) { double x = (double)SvNV(nv); return newSVnv(x); } EOC print perl_foo(2.5), "\n"; print perl_foo(1.1), "\n"; # LINE 17 sub perl_foo { my $ret = foo($_[0]); if($_[0] - $ret) {warn "Loss of precision"} # LINE 21 return $ret; }
On a (linux, mdk-9.1) perl built with long double support it prints out (transcribed, not copy'n'pasted):2.5 1.1
The key points to the exercise are:2.5 Loss of precision at double.pl line 21 1.10000000000000009
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XS, C doubles and -Duselongdouble
by BrowserUk (Patriarch) on Jun 10, 2007 at 12:52 UTC | |
by syphilis (Archbishop) on Jun 10, 2007 at 14:26 UTC | |
by BrowserUk (Patriarch) on Jun 10, 2007 at 15:17 UTC | |
by syphilis (Archbishop) on Jun 10, 2007 at 15:35 UTC | |
by BrowserUk (Patriarch) on Jun 10, 2007 at 17:03 UTC | |
|
Re: XS, C doubles and -Duselongdouble
by ysth (Canon) on Jun 11, 2007 at 03:25 UTC | |
by syphilis (Archbishop) on Jun 11, 2007 at 07:32 UTC | |
by ysth (Canon) on Jun 11, 2007 at 07:40 UTC |