Consider the following program:
$x=12345678901.234567000; $y=($x-int($x))*1000000000; printf("%f:%f\n",$x,$y);
Here is what prints:
12345678901.234568:234567642.211914
I expected:
12345678901.234567:234567000
This is similar to the rounding problem in Perl.How can I change it to get 234567000instead?Did I do something wrong?
234567000
Make "use bignum ;" first line of your program.
, - . , . , , "bignum". , , , .
, , , . .
.
(, 19.9499999999999) , (, 19.95)?, . ( ) . . , , Perl.perlnumber . , printf sprintf. . .printf "%.2f", 10/3; my $number = sprintf "%.2f", 10/3;
, . ( ) . . , , Perl.
perlnumber . , printf sprintf. . .
printf
sprintf
printf "%.2f", 10/3; my $number = sprintf "%.2f", 10/3;
, , bignum. ? printf. bignum - . , . , bignum Perl , printf C. %f .
bignum
%f
print, . .
print
, , Perl -Duse64bitint -Duselongdouble, Perl 64- long double . , (bignum - hog ). 100% , bignum, , printf. Perl , . , Perl (/usr/local/perl/64bit - ), Perl, .
-Duse64bitint -Duselongdouble
long double
/usr/local/perl/64bit
(Googlework?) : , ?
, , , ( ). $x 8.
$x
8
$x - (int($x) - 0.23456linenoise, . 1000000000, , , .
$x - (int($x)
0.23456linenoise
Perl . , $x . , :
$ perl -e 'printf "%.10f", 12345678901.234567000' 12345678901.2345676422
Source: https://habr.com/ru/post/1754322/More articles:Can I get the name of the terminal? (or otherwise restore the old one) - terminalShould I comment correctly on this fragment of my request? - sql-serverhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1754319/is-there-a-way-to-force-pdfs-to-open-in-adobe-reader-rather-than-in-plugins&usg=ALkJrhg2jBugWeETO91Pbra74OpMM0rQhgXerces C ++: no error for a nonexistent file - c ++Google Maps API for Android in WallpaperService (live wallpaper) - androidGet Thumb Slider - wpfregularly view other computers on the network in Python - pythonGetting "nothing has changed" when making a transaction in Mercurial with Google code - mercurialHow to click "OK" as soon as you change the IE software proxy - c #Find center point of UIScrollView when scaling - iphoneAll Articles