From: Jarkko Hietaniemi Date: Thu, 13 Jun 2002 21:59:07 +0000 (+0000) Subject: Don't assume too much about how print will scale X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2bea9a372691b6c02bfc2bf2bd27ffe114c228e1;p=p5sagit%2Fp5-mst-13.2.git Don't assume too much about how print will scale your fp numbers; be explicit and use printf instead-- the assumption broke in UNICOS (from Mark Lutz) (Use %.0f instead of %d because in 32-bit systems the %d may end producing -1 or something else odd.) p4raw-id: //depot/perl@17225 --- diff --git a/t/lib/warnings/toke b/t/lib/warnings/toke index d2695d6..0a5346a 100644 --- a/t/lib/warnings/toke +++ b/t/lib/warnings/toke @@ -378,20 +378,20 @@ $a = -123._456; print "$a\n"; # 25 $a = -123.4_56; print "$a\n"; $a = -123.45_6; print "$a\n"; $a = -123.456_; print "$a\n"; # 28 -$a = 123.456E_12; print "$a\n"; # 29 -$a = 123.456E1_2; print "$a\n"; -$a = 123.456E12_; print "$a\n"; # 31 -$a = 123.456E_+12; print "$a\n"; # 32 -$a = 123.456E+_12; print "$a\n"; # 33 -$a = 123.456E+1_2; print "$a\n"; -$a = 123.456E+12_; print "$a\n"; # 35 +$a = 123.456E_12; printf("%.0f\n", $a); # 29 +$a = 123.456E1_2; printf("%.0f\n", $a); +$a = 123.456E12_; printf("%.0f\n", $a); # 31 +$a = 123.456E_+12; printf("%.0f\n", $a); # 32 +$a = 123.456E+_12; printf("%.0f\n", $a); # 33 +$a = 123.456E+1_2; printf("%.0f\n", $a); +$a = 123.456E+12_; printf("%.0f\n", $a); # 35 $a = 123.456E_-12; print "$a\n"; # 36 $a = 123.456E-_12; print "$a\n"; # 37 $a = 123.456E-1_2; print "$a\n"; $a = 123.456E-12_; print "$a\n"; # 39 $a = 1__23; print "$a\n"; # 40 $a = 12.3__4; print "$a\n"; # 41 -$a = 12.34e1__2; print "$a\n"; # 42 +$a = 12.34e1__2; printf("%.0f\n", $a); # 42 no warnings 'syntax' ; $a = _123; print "$a\n"; $a = 1_23; print "$a\n"; @@ -419,20 +419,20 @@ $a = -123._456; print "$a\n"; $a = -123.4_56; print "$a\n"; $a = -123.45_6; print "$a\n"; $a = -123.456_; print "$a\n"; -$a = 123.456E_12; print "$a\n"; -$a = 123.456E1_2; print "$a\n"; -$a = 123.456E12_; print "$a\n"; -$a = 123.456E_+12; print "$a\n"; -$a = 123.456E+_12; print "$a\n"; -$a = 123.456E+1_2; print "$a\n"; -$a = 123.456E+12_; print "$a\n"; +$a = 123.456E_12; printf("%.0f\n", $a); +$a = 123.456E1_2; printf("%.0f\n", $a); +$a = 123.456E12_; printf("%.0f\n", $a); +$a = 123.456E_+12; printf("%.0f\n", $a); +$a = 123.456E+_12; printf("%.0f\n", $a); +$a = 123.456E+1_2; printf("%.0f\n", $a); +$a = 123.456E+12_; printf("%.0f\n", $a); $a = 123.456E_-12; print "$a\n"; $a = 123.456E-_12; print "$a\n"; $a = 123.456E-1_2; print "$a\n"; $a = 123.456E-12_; print "$a\n"; $a = 1__23; print "$a\n"; $a = 12.3__4; print "$a\n"; -$a = 12.34e1__2; print "$a\n"; +$a = 12.34e1__2; printf("%.0f\n", $a); EXPECT OPTIONS regex Misplaced _ in number at - line 6.