in reply to Rounding off ?
Somehow, your BigInts are transformed into double-precision floating point numbers before being handed to printf:
But you can use as_hex() of Math::BigInt (also available in new versions: to_hex()) to get the original hex representation back:$ tcc -run - #include <inttypes.h> #include <stdint.h> #include <stdio.h> int main(void) { printf("%" PRIx64 "\n", (uint64_t)(double)0x3243bcfe21ef4468ULL); return 0; } ^D 3243bcfe21ef4400
$ perl -MMath::BigInt -E'say Math::BigInt->new("0x3243bcfe21ef4468")-> +as_hex' 0x3243bcfe21ef4468
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Rounding off ?
by syphilis (Archbishop) on Sep 15, 2018 at 08:16 UTC | |
by Anonymous Monk on Sep 15, 2018 at 19:25 UTC |