in reply to Rounding off ?
I can't reproduce that here, I'm getting the output:
3243BCFE21EF4468 EF453276BDBDE566 2342ED65876AB55F
Maybe you're on a 32-bit build of Perl?* Also, what version of Perl are you on? Maybe you could post the output of perl -V here.
Anyway, yes, it's possible you're seeing some rounding effects, although I'm not sure exactly what since I can't see it here. printf is probably numifying the object into a regular Perl number, which may not be large enough to hold the value*. However, Math::BigInt provides the as_hex method:
use warnings; use strict; use Math::BigInt; my @CRCTable = ( Math::BigInt->new("0x3243bcfe21ef4468"), Math::BigInt->new("0xef453276bdbde566"), Math::BigInt->new("0x2342ed65876ab55f"), ); for my $crc (@CRCTable) { print $crc->as_hex, "\n"; } __END__ 0x3243bcfe21ef4468 0xef453276bdbde566 0x2342ed65876ab55f
* Update: Based on the replies I have to revise my guess: maybe you are doing some operations on the BitInts that you haven't shown here? Are you certain that the output you've posted here is exactly what you get when you run the exact code you've posted here? If yes, maybe there's something different about your build of Perl. In addition to the output of perl -V, please show the output of perl -MMath::BigInt -le 'print $Math::BigInt::VERSION'.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Rounding off ?
by Your Mother (Archbishop) on Sep 13, 2018 at 23:03 UTC | |
|
Re^2: Rounding off ?
by rizzo (Curate) on Sep 14, 2018 at 02:20 UTC | |
by haukex (Archbishop) on Sep 14, 2018 at 08:24 UTC | |
|
Re^2: Rounding off ?
by hippo (Archbishop) on Sep 14, 2018 at 08:08 UTC | |
|
Re^2: Rounding off ? (updated)
by syphilis (Archbishop) on Sep 14, 2018 at 12:56 UTC | |
|
Re^2: Rounding off ? (updated)
by Zomalaja (Initiate) on Sep 14, 2018 at 14:52 UTC |