in reply to substitution "0" in decimals
DB<1> $d1 = '1230.1200'; DB<2> print $d1 1230.1200 DB<3> print $d1+0 1230.12 DB<4> $d1=$d1+0 DB<5> print $d1 1230.12
Cheers Rolf
UPDATE: Please be aware about the limitations of floating-point-numbers as illustrated in the folowing example
DB<1> $a='0.0000001'; DB<2> print $a+0 1e-07 DB<3> printf "%s",$a 0.0000001 DB<4> $a=sprintf "%s",$a DB<5> print $a 0.0000001 DB<7> $a='0.00000000000000000000000000000000001000000000000000'; DB<8> $a=sprintf "%s",$a+0 DB<9> print $a 1e-35
If you just wanna reformat a string avoiding any float-representation , you should better consider taking the regex from kennethk's posting!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: substitution "0" in decimals
by Sun751 (Beadle) on Dec 08, 2009 at 00:01 UTC | |
by AnomalousMonk (Archbishop) on Dec 08, 2009 at 00:30 UTC | |
by LanX (Saint) on Dec 08, 2009 at 00:51 UTC | |
|
Re^2: substitution "0" in decimals
by JavaFan (Canon) on Dec 08, 2009 at 10:48 UTC | |
by LanX (Saint) on Dec 08, 2009 at 11:57 UTC | |
by JavaFan (Canon) on Dec 08, 2009 at 12:57 UTC | |
by LanX (Saint) on Dec 08, 2009 at 13:22 UTC |