mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-17 16:32:11 +01:00
Fix script/print-mpb-powers-of-10.go with -detail
This commit is contained in:
1 parent
54e20636e8
commit
1bc98b6035
1 file changed
+43
-3
@@ -16,10 +16,50 @@
|
||||
|
||||
package main
|
||||
|
||||
// print-mpb-powers-of-10.go prints the medium-precision (128 bit mantissa)
|
||||
// binary (base 2) wuffs_base__private_implementation__powers_of_10 tables.
|
||||
// print-mpb-powers-of-10.go prints the medium-precision (128-bit mantissa)
|
||||
// binary (base-2) wuffs_base__private_implementation__powers_of_10 tables.
|
||||
//
|
||||
// When the approximation to (10 ** N) is not exact, the mantissa is truncated,
|
||||
// not rounded to nearest. The base-2 exponent is chosen so that the mantissa's
|
||||
// most signficant bit (bit 127) is set.
|
||||
//
|
||||
// The final uint32_t entry in each row-of-5 is biased by 1214, also known as
|
||||
// 0x04BE, which simplifies its use in f64conv-submodule.c.
|
||||
//
|
||||
// Usage: go run print-mpb-powers-of-10.go -detail
|
||||
//
|
||||
// With -detail set, its output should include:
|
||||
//
|
||||
// 0xF7604B57, 0x014BB630, 0xFE98746D, 0x84A57695, 0x0004,
|
||||
// // 1e-326 ≈ (0x84A57695FE98746D014BB630F7604B57 >> 1210)
|
||||
//
|
||||
// 0x35385E2D, 0x419EA3BD, 0x7E3E9188, 0xA5CED43B, 0x0007,
|
||||
// // 1e-325 ≈ (0xA5CED43B7E3E9188419EA3BD35385E2D >> 1207)
|
||||
//
|
||||
// ...
|
||||
//
|
||||
// 0x0A3D70A3, 0x3D70A3D7, 0x70A3D70A, 0xA3D70A3D, 0x0438,
|
||||
// // 1e-2 ≈ (0xA3D70A3D70A3D70A3D70A3D70A3D70A3 >> 134)
|
||||
//
|
||||
// 0xCCCCCCCC, 0xCCCCCCCC, 0xCCCCCCCC, 0xCCCCCCCC, 0x043B,
|
||||
// // 1e-1 ≈ (0xCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC >> 131)
|
||||
//
|
||||
// 0x00000000, 0x00000000, 0x00000000, 0x80000000, 0x043F,
|
||||
// // 1e0 ≈ (0x80000000000000000000000000000000 >> 127)
|
||||
//
|
||||
// 0x00000000, 0x00000000, 0x00000000, 0xA0000000, 0x0442,
|
||||
// // 1e1 ≈ (0xA0000000000000000000000000000000 >> 124)
|
||||
//
|
||||
// 0x00000000, 0x00000000, 0x00000000, 0xC8000000, 0x0445,
|
||||
// // 1e2 ≈ (0xC8000000000000000000000000000000 >> 121)
|
||||
//
|
||||
// ...
|
||||
//
|
||||
// 0x51E513DA, 0x2CD2CC65, 0x35D63F73, 0xB201833B, 0x0841,
|
||||
// // 1e309 ≈ (0xB201833B35D63F732CD2CC6551E513DA << 899)
|
||||
//
|
||||
// 0xA65E58D1, 0xF8077F7E, 0x034BCF4F, 0xDE81E40A, 0x0844,
|
||||
// // 1e310 ≈ (0xDE81E40A034BCF4FF8077F7EA65E58D1 << 902)
|
||||
|
||||
import (
|
||||
"flag"
|
||||
@@ -91,7 +131,7 @@ func do(e int) error {
|
||||
fmt.Printf(" 0x%s, 0x%s, 0x%s, 0x%s, 0x%04X, // 1e%-04d",
|
||||
hex[24:], hex[16:24], hex[8:16], hex[:8], uint32(n)+bias, e)
|
||||
if *detail {
|
||||
fmt.Printf("≈ (0x%s ", e, hex)
|
||||
fmt.Printf(" ≈ (0x%s ", hex)
|
||||
if n >= 0 {
|
||||
fmt.Printf("<< %4d)", +n)
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user