const TEST_DATA: &[u32] = &[ 0x00000000, 0x00000001, 0x00000002, 0x00000002, 0x00000001, 0x00000002, 0x00000003, 0x00000003, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000c, 0x0000000f, 0x00000010, 0x00000011, 0x00000018, 0x0000001f, 0x00000020, 0x00000021, 0x00000030, 0x0000003f, 0x00000040, 0x00000041, 0x00000060, 0x0000007f, 0x00000080, 0x00000081, 0x000000c0, 0x000000ff, 0x00000100, 0x00000101, 0x00000180, 0x000001ff, 0x00000200, 0x00000201, 0x00000300, 0x000003ff, 0x00000400, 0x00000401, 0x00000600, 0x000007ff, 0x00000800, 0x00000801, 0x00000c00, 0x00000fff, 0x00001000, 0x00001001, 0x00001800, 0x00001fff, 0x00002000, 0x00002001, 0x00003000, 0x00003fff, 0x00004000, 0x00004001, 0x00006000, 0x00007fff, 0x00008000, 0x00008001, 0x0000c000, 0x0000ffff, 0x00010000, 0x00010001, 0x00018000, 0x0001ffff, 0x00020000, 0x00020001, 0x00030000, 0x0003ffff, 0x00040000, 0x00040001, 0x00060000, 0x0007ffff, 0x00080000, 0x00080001, 0x000c0000, 0x000fffff, 0x00100000, 0x00100001, 0x00180000, 0x001fffff, 0x00200000, 0x00200001, 0x00300000, 0x003fffff, 0x00400000, 0x00400001, 0x00600000, 0x007fffff, 0x00800000, 0x00800001, 0x00c00000, 0x00ffffff, 0x01000000, 0x01000001, 0x01400000, 0x017fffff, 0x01800000, 0x01800001, 0x01c00000, 0x01ffffff, 0x02000000, 0x02000001, 0x02400000, 0x027fffff, 0x02800000, 0x02800001, 0x02c00000, 0x02ffffff, 0x03000000, 0x03000001, 0x03400000, 0x037fffff, 0x03800000, 0x03800001, 0x03c00000, 0x03ffffff, 0x04000000, 0x04000001, 0x04400000, 0x047fffff, 0x04800000, 0x04800001, 0x04c00000, 0x04ffffff, 0x05000000, 0x05000001, 0x05400000, 0x057fffff, 0x05800000, 0x05800001, 0x05c00000, 0x05ffffff, 0x06000000, 0x06000001, 0x06400000, 0x067fffff, 0x06800000, 0x06800001, 0x06c00000, 0x06ffffff, 0x07000000, 0x07000001, 0x07400000, 0x077fffff, 0x07800000, 0x07800001, 0x07c00000, 0x07ffffff, 0x08000000, 0x08000001, 0x08400000, 0x087fffff, 0x08800000, 0x08800001, 0x08c00000, 0x08ffffff, 0x09000000, 0x09000001, 0x09400000, 0x097fffff, 0x09800000, 0x09800001, 0x09c00000, 0x09ffffff, 0x0a000000, 0x0a000001, 0x0a400000, 0x0a7fffff, 0x0a800000, 0x0a800001, 0x0ac00000, 0x0affffff, 0x0b000000, 0x0b000001, 0x0b400000, 0x0b7fffff, 0x0b800000, 0x0b800001, 0x0bc00000, 0x0bffffff, 0x0c000000, 0x0c000001, 0x0c400000, 0x0c7fffff, 0x0c800000, 0x0c800001, 0x0cc00000, 0x0cffffff, 0x0d000000, 0x0d000001, 0x0d400000, 0x0d7fffff, 0x0d800000, 0x0d800001, 0x0dc00000, 0x0dffffff, 0x0e000000, 0x0e000001, 0x0e400000, 0x0e7fffff, 0x0e800000, 0x0e800001, 0x0ec00000, 0x0effffff, 0x0f000000, 0x0f000001, 0x0f400000, 0x0f7fffff, 0x0f800000, 0x0f800001, 0x0fc00000, 0x0fffffff, 0x10000000, 0x10000001, 0x10400000, 0x107fffff, 0x10800000, 0x10800001, 0x10c00000, 0x10ffffff, 0x11000000, 0x11000001, 0x11400000, 0x117fffff, 0x11800000, 0x11800001, 0x11c00000, 0x11ffffff, 0x12000000, 0x12000001, 0x12400000, 0x127fffff, 0x12800000, 0x12800001, 0x12c00000, 0x12ffffff, 0x13000000, 0x13000001, 0x13400000, 0x137fffff, 0x13800000, 0x13800001, 0x13c00000, 0x13ffffff, 0x14000000, 0x14000001, 0x14400000, 0x147fffff, 0x14800000, 0x14800001, 0x14c00000, 0x14ffffff, 0x15000000, 0x15000001, 0x15400000, 0x157fffff, 0x15800000, 0x15800001, 0x15c00000, 0x15ffffff, 0x16000000, 0x16000001, 0x16400000, 0x167fffff, 0x16800000, 0x16800001, 0x16c00000, 0x16ffffff, 0x17000000, 0x17000001, 0x17400000, 0x177fffff, 0x17800000, 0x17800001, 0x17c00000, 0x17ffffff, 0x18000000, 0x18000001, 0x18400000, 0x187fffff, 0x18800000, 0x18800001, 0x18c00000, 0x18ffffff, 0x19000000, 0x19000001, 0x19400000, 0x197fffff, 0x19800000, 0x19800001, 0x19c00000, 0x19ffffff, 0x1a000000, 0x1a000001, 0x1a400000, 0x1a7fffff, 0x1a800000, 0x1a800001, 0x1ac00000, 0x1affffff, 0x1b000000, 0x1b000001, 0x1b400000, 0x1b7fffff, 0x1b800000, 0x1b800001, 0x1bc00000, 0x1bffffff, 0x1c000000, 0x1c000001, 0x1c400000, 0x1c7fffff, 0x1c800000, 0x1c800001, 0x1cc00000, 0x1cffffff, 0x1d000000, 0x1d000001, 0x1d400000, 0x1d7fffff, 0x1d800000, 0x1d800001, 0x1dc00000, 0x1dffffff, 0x1e000000, 0x1e000001, 0x1e400000, 0x1e7fffff, 0x1e800000, 0x1e800001, 0x1ec00000, 0x1effffff, 0x1f000000, 0x1f000001, 0x1f400000, 0x1f7fffff, 0x1f800000, 0x1f800001, 0x1fc00000, 0x1fffffff, 0x20000000, 0x20000001, 0x20400000, 0x207fffff, 0x20800000, 0x20800001, 0x20c00000, 0x20ffffff, 0x21000000, 0x21000001, 0x21400000, 0x217fffff, 0x21800000, 0x21800001, 0x21c00000, 0x21ffffff, 0x22000000, 0x22000001, 0x22400000, 0x227fffff, 0x22800000, 0x22800001, 0x22c00000, 0x22ffffff, 0x23000000, 0x23000001, 0x23400000, 0x237fffff, 0x23800000, 0x23800001, 0x23c00000, 0x23ffffff, 0x24000000, 0x24000001, 0x24400000, 0x247fffff, 0x24800000, 0x24800001, 0x24c00000, 0x24ffffff, 0x25000000, 0x25000001, 0x25400000, 0x257fffff, 0x25800000, 0x25800001, 0x25c00000, 0x25ffffff, 0x26000000, 0x26000001, 0x26400000, 0x267fffff, 0x26800000, 0x26800001, 0x26c00000, 0x26ffffff, 0x27000000, 0x27000001, 0x27400000, 0x277fffff, 0x27800000, 0x27800001, 0x27c00000, 0x27ffffff, 0x28000000, 0x28000001, 0x28400000, 0x287fffff, 0x28800000, 0x28800001, 0x28c00000, 0x28ffffff, 0x29000000, 0x29000001, 0x29400000, 0x297fffff, 0x29800000, 0x29800001, 0x29c00000, 0x29ffffff, 0x2a000000, 0x2a000001, 0x2a400000, 0x2a7fffff, 0x2a800000, 0x2a800001, 0x2ac00000, 0x2affffff, 0x2b000000, 0x2b000001, 0x2b400000, 0x2b7fffff, 0x2b800000, 0x2b800001, 0x2bc00000, 0x2bffffff, 0x2c000000, 0x2c000001, 0x2c400000, 0x2c7fffff, 0x2c800000, 0x2c800001, 0x2cc00000, 0x2cffffff, 0x2d000000, 0x2d000001, 0x2d400000, 0x2d7fffff, 0x2d800000, 0x2d800001, 0x2dc00000, 0x2dffffff, 0x2e000000, 0x2e000001, 0x2e400000, 0x2e7fffff, 0x2e800000, 0x2e800001, 0x2ec00000, 0x2effffff, 0x2f000000, 0x2f000001, 0x2f400000, 0x2f7fffff, 0x2f800000, 0x2f800001, 0x2fc00000, 0x2fffffff, 0x30000000, 0x30000001, 0x30400000, 0x307fffff, 0x30800000, 0x30800001, 0x30c00000, 0x30ffffff, 0x31000000, 0x31000001, 0x31400000, 0x317fffff, 0x31800000, 0x31800001, 0x31c00000, 0x31ffffff, 0x32000000, 0x32000001, 0x32400000, 0x327fffff, 0x32800000, 0x32800001, 0x32c00000, 0x32ffffff, 0x33000000, 0x33000001, 0x33400000, 0x337fffff, 0x33800000, 0x33800001, 0x33c00000, 0x33ffffff, 0x34000000, 0x34000001, 0x34400000, 0x347fffff, 0x34800000, 0x34800001, 0x34c00000, 0x34ffffff, 0x35000000, 0x35000001, 0x35400000, 0x357fffff, 0x35800000, 0x35800001, 0x35c00000, 0x35ffffff, 0x36000000, 0x36000001, 0x36400000, 0x367fffff, 0x36800000, 0x36800001, 0x36c00000, 0x36ffffff, 0x37000000, 0x37000001, 0x37400000, 0x377fffff, 0x37800000, 0x37800001, 0x37c00000, 0x37ffffff, 0x38000000, 0x38000001, 0x38400000, 0x387fffff, 0x38800000, 0x38800001, 0x38c00000, 0x38ffffff, 0x39000000, 0x39000001, 0x39400000, 0x397fffff, 0x39800000, 0x39800001, 0x39c00000, 0x39ffffff, 0x3a000000, 0x3a000001, 0x3a400000, 0x3a7fffff, 0x3a800000, 0x3a800001, 0x3ac00000, 0x3affffff, 0x3b000000, 0x3b000001, 0x3b400000, 0x3b7fffff, 0x3b800000, 0x3b800001, 0x3bc00000, 0x3bffffff, 0x3c000000, 0x3c000001, 0x3c400000, 0x3c7fffff, 0x3c800000, 0x3c800001, 0x3cc00000, 0x3cffffff, 0x3d000000, 0x3d000001, 0x3d400000, 0x3d7fffff, 0x3d800000, 0x3d800001, 0x3dc00000, 0x3dffffff, 0x3e000000, 0x3e000001, 0x3e400000, 0x3e7fffff, 0x3e800000, 0x3e800001, 0x3ec00000, 0x3effffff, 0x3f000000, 0x3f000001, 0x3f400000, 0x3f7fffff, 0x3f800000, 0x3f800001, 0x3fc00000, 0x3fffffff, 0x40000000, 0x40000001, 0x40400000, 0x407fffff, 0x40800000, 0x40800001, 0x40c00000, 0x40ffffff, 0x41000000, 0x41000001, 0x41400000, 0x417fffff, 0x41800000, 0x41800001, 0x41c00000, 0x41ffffff, 0x42000000, 0x42000001, 0x42400000, 0x427fffff, 0x42800000, 0x42800001, 0x42c00000, 0x42ffffff, 0x43000000, 0x43000001, 0x43400000, 0x437fffff, 0x43800000, 0x43800001, 0x43c00000, 0x43ffffff, 0x44000000, 0x44000001, 0x44400000, 0x447fffff, 0x44800000, 0x44800001, 0x44c00000, 0x44ffffff, 0x45000000, 0x45000001, 0x45400000, 0x457fffff, 0x45800000, 0x45800001, 0x45c00000, 0x45ffffff, 0x46000000, 0x46000001, 0x46400000, 0x467fffff, 0x46800000, 0x46800001, 0x46c00000, 0x46ffffff, 0x47000000, 0x47000001, 0x47400000, 0x477fffff, 0x47800000, 0x47800001, 0x47c00000, 0x47ffffff, 0x48000000, 0x48000001, 0x48400000, 0x487fffff, 0x48800000, 0x48800001, 0x48c00000, 0x48ffffff, 0x49000000, 0x49000001, 0x49400000, 0x497fffff, 0x49800000, 0x49800001, 0x49c00000, 0x49ffffff, 0x4a000000, 0x4a000001, 0x4a400000, 0x4a7fffff, 0x4a800000, 0x4a800001, 0x4ac00000, 0x4affffff, 0x4b000000, 0x4b000001, 0x4b400000, 0x4b7fffff, 0x4b800000, 0x4b800001, 0x4bc00000, 0x4bffffff, 0x4c000000, 0x4c000001, 0x4c400000, 0x4c7fffff, 0x4c800000, 0x4c800001, 0x4cc00000, 0x4cffffff, 0x4d000000, 0x4d000001, 0x4d400000, 0x4d7fffff, 0x4d800000, 0x4d800001, 0x4dc00000, 0x4dffffff, 0x4e000000, 0x4e000001, 0x4e400000, 0x4e7fffff, 0x4e800000, 0x4e800001, 0x4ec00000, 0x4effffff, 0x4f000000, 0x4f000001, 0x4f400000, 0x4f7fffff, 0x4f800000, 0x4f800001, 0x4fc00000, 0x4fffffff, 0x50000000, 0x50000001, 0x50400000, 0x507fffff, 0x50800000, 0x50800001, 0x50c00000, 0x50ffffff, 0x51000000, 0x51000001, 0x51400000, 0x517fffff, 0x51800000, 0x51800001, 0x51c00000, 0x51ffffff, 0x52000000, 0x52000001, 0x52400000, 0x527fffff, 0x52800000, 0x52800001, 0x52c00000, 0x52ffffff, 0x53000000, 0x53000001, 0x53400000, 0x537fffff, 0x53800000, 0x53800001, 0x53c00000, 0x53ffffff, 0x54000000, 0x54000001, 0x54400000, 0x547fffff, 0x54800000, 0x54800001, 0x54c00000, 0x54ffffff, 0x55000000, 0x55000001, 0x55400000, 0x557fffff, 0x55800000, 0x55800001, 0x55c00000, 0x55ffffff, 0x56000000, 0x56000001, 0x56400000, 0x567fffff, 0x56800000, 0x56800001, 0x56c00000, 0x56ffffff, 0x57000000, 0x57000001, 0x57400000, 0x577fffff, 0x57800000, 0x57800001, 0x57c00000, 0x57ffffff, 0x58000000, 0x58000001, 0x58400000, 0x587fffff, 0x58800000, 0x58800001, 0x58c00000, 0x58ffffff, 0x59000000, 0x59000001, 0x59400000, 0x597fffff, 0x59800000, 0x59800001, 0x59c00000, 0x59ffffff, 0x5a000000, 0x5a000001, 0x5a400000, 0x5a7fffff, 0x5a800000, 0x5a800001, 0x5ac00000, 0x5affffff, 0x5b000000, 0x5b000001, 0x5b400000, 0x5b7fffff, 0x5b800000, 0x5b800001, 0x5bc00000, 0x5bffffff, 0x5c000000, 0x5c000001, 0x5c400000, 0x5c7fffff, 0x5c800000, 0x5c800001, 0x5cc00000, 0x5cffffff, 0x5d000000, 0x5d000001, 0x5d400000, 0x5d7fffff, 0x5d800000, 0x5d800001, 0x5dc00000, 0x5dffffff, 0x5e000000, 0x5e000001, 0x5e400000, 0x5e7fffff, 0x5e800000, 0x5e800001, 0x5ec00000, 0x5effffff, 0x5f000000, 0x5f000001, 0x5f400000, 0x5f7fffff, 0x5f800000, 0x5f800001, 0x5fc00000, 0x5fffffff, 0x60000000, 0x60000001, 0x60400000, 0x607fffff, 0x60800000, 0x60800001, 0x60c00000, 0x60ffffff, 0x61000000, 0x61000001, 0x61400000, 0x617fffff, 0x61800000, 0x61800001, 0x61c00000, 0x61ffffff, 0x62000000, 0x62000001, 0x62400000, 0x627fffff, 0x62800000, 0x62800001, 0x62c00000, 0x62ffffff, 0x63000000, 0x63000001, 0x63400000, 0x637fffff, 0x63800000, 0x63800001, 0x63c00000, 0x63ffffff, 0x64000000, 0x64000001, 0x64400000, 0x647fffff, 0x64800000, 0x64800001, 0x64c00000, 0x64ffffff, 0x65000000, 0x65000001, 0x65400000, 0x657fffff, 0x65800000, 0x65800001, 0x65c00000, 0x65ffffff, 0x66000000, 0x66000001, 0x66400000, 0x667fffff, 0x66800000, 0x66800001, 0x66c00000, 0x66ffffff, 0x67000000, 0x67000001, 0x67400000, 0x677fffff, 0x67800000, 0x67800001, 0x67c00000, 0x67ffffff, 0x68000000, 0x68000001, 0x68400000, 0x687fffff, 0x68800000, 0x68800001, 0x68c00000, 0x68ffffff, 0x69000000, 0x69000001, 0x69400000, 0x697fffff, 0x69800000, 0x69800001, 0x69c00000, 0x69ffffff, 0x6a000000, 0x6a000001, 0x6a400000, 0x6a7fffff, 0x6a800000, 0x6a800001, 0x6ac00000, 0x6affffff, 0x6b000000, 0x6b000001, 0x6b400000, 0x6b7fffff, 0x6b800000, 0x6b800001, 0x6bc00000, 0x6bffffff, 0x6c000000, 0x6c000001, 0x6c400000, 0x6c7fffff, 0x6c800000, 0x6c800001, 0x6cc00000, 0x6cffffff, 0x6d000000, 0x6d000001, 0x6d400000, 0x6d7fffff, 0x6d800000, 0x6d800001, 0x6dc00000, 0x6dffffff, 0x6e000000, 0x6e000001, 0x6e400000, 0x6e7fffff, 0x6e800000, 0x6e800001, 0x6ec00000, 0x6effffff, 0x6f000000, 0x6f000001, 0x6f400000, 0x6f7fffff, 0x6f800000, 0x6f800001, 0x6fc00000, 0x6fffffff, 0x70000000, 0x70000001, 0x70400000, 0x707fffff, 0x70800000, 0x70800001, 0x70c00000, 0x70ffffff, 0x71000000, 0x71000001, 0x71400000, 0x717fffff, 0x71800000, 0x71800001, 0x71c00000, 0x71ffffff, 0x72000000, 0x72000001, 0x72400000, 0x727fffff, 0x72800000, 0x72800001, 0x72c00000, 0x72ffffff, 0x73000000, 0x73000001, 0x73400000, 0x737fffff, 0x73800000, 0x73800001, 0x73c00000, 0x73ffffff, 0x74000000, 0x74000001, 0x74400000, 0x747fffff, 0x74800000, 0x74800001, 0x74c00000, 0x74ffffff, 0x75000000, 0x75000001, 0x75400000, 0x757fffff, 0x75800000, 0x75800001, 0x75c00000, 0x75ffffff, 0x76000000, 0x76000001, 0x76400000, 0x767fffff, 0x76800000, 0x76800001, 0x76c00000, 0x76ffffff, 0x77000000, 0x77000001, 0x77400000, 0x777fffff, 0x77800000, 0x77800001, 0x77c00000, 0x77ffffff, 0x78000000, 0x78000001, 0x78400000, 0x787fffff, 0x78800000, 0x78800001, 0x78c00000, 0x78ffffff, 0x79000000, 0x79000001, 0x79400000, 0x797fffff, 0x79800000, 0x79800001, 0x79c00000, 0x79ffffff, 0x7a000000, 0x7a000001, 0x7a400000, 0x7a7fffff, 0x7a800000, 0x7a800001, 0x7ac00000, 0x7affffff, 0x7b000000, 0x7b000001, 0x7b400000, 0x7b7fffff, 0x7b800000, 0x7b800001, 0x7bc00000, 0x7bffffff, 0x7c000000, 0x7c000001, 0x7c400000, 0x7c7fffff, 0x7c800000, 0x7c800001, 0x7cc00000, 0x7cffffff, 0x7d000000, 0x7d000001, 0x7d400000, 0x7d7fffff, 0x7d800000, 0x7d800001, 0x7dc00000, 0x7dffffff, 0x7e000000, 0x7e000001, 0x7e400000, 0x7e7fffff, 0x7e800000, 0x7e800001, 0x7ec00000, 0x7effffff, 0x7f000000, 0x7f000001, 0x7f400000, 0x7f800000, ]; macro_rules! assert_almost_equal { ($a:expr, $b:expr) => { assert!( almost::equal($a, $b), "should be almost equal: {} ({:x}) and {} ({:x})", $a, $a.to_bits(), $b, $b.to_bits()); }; ($a:expr, $b:expr, $tol:expr) => { assert!( almost::equal_with($a, $b, $tol), "should be almost equal: {} ({:x}) and {} ({:x}) using tol {} ({:x})", $a, $a.to_bits(), $b, $b.to_bits(), $tol, $tol.to_bits()); }; } macro_rules! assert_not_almost_equal { ($a:expr, $b:expr) => { assert!( !almost::equal($a, $b), "should not be almost equal: {} ({:x}) and {} ({:x})", $a, $a.to_bits(), $b, $b.to_bits()); }; ($a:expr, $b:expr, $tol:expr) => { assert!( !almost::equal_with($a, $b, $tol), "should not be almost equal: {} ({:x}) and {} ({:x}) using tol {} ({:x})", $a, $a.to_bits(), $b, $b.to_bits(), $tol, $tol.to_bits()); }; } #[test] fn test_f32() { use ieee754::Ieee754; use rand::{prelude::*, distributions::Uniform, rngs::SmallRng}; let mut rng = SmallRng::seed_from_u64(TEST_DATA.as_ptr() as usize as u64); let tolerance_dist = Uniform::new_inclusive(std::f32::EPSILON, 1.0.prev()); let mut tolerances = [ std::f32::EPSILON * 2.0, almost::F32_TOLERANCE, 1.0f32.prev(), 0.0, 0.0, 0.0, 0.0, 0.0 ]; for i in 3..tolerances.len() { tolerances[i] = tolerance_dist.sample(&mut rng); } assert_not_almost_equal!(std::f32::NAN, std::f32::NAN); for &tol in &tolerances { assert_not_almost_equal!(std::f32::NAN, std::f32::NAN, tol); } for &u in TEST_DATA { let f = f32::from_bits(u); assert_not_almost_equal!(f, std::f32::NAN); assert_not_almost_equal!(std::f32::NAN, f); for &tol in &tolerances { assert_not_almost_equal!(f, std::f32::NAN, tol); assert_not_almost_equal!(std::f32::NAN, f, tol); } } for &u in TEST_DATA { let f = f32::from_bits(u); assert_almost_equal!(f, f); assert_almost_equal!(f, f.prev()); assert_almost_equal!(f.prev(), f); assert_almost_equal!(-f, -f); assert_almost_equal!(-f, (-f).next()); assert_almost_equal!((-f).next(), -f); if f != std::f32::INFINITY { assert_almost_equal!(f, f.next()); assert_almost_equal!(f.next(), f); assert_almost_equal!(-f, (-f).prev()); assert_almost_equal!((-f).prev(), -f); } for &tol in &tolerances { assert_almost_equal!(f, f, tol); assert_almost_equal!(f, f.prev(), tol); assert_almost_equal!(f.prev(), f, tol); assert_almost_equal!(-f, -f, tol); assert_almost_equal!(-f, (-f).next(), tol); assert_almost_equal!((-f).next(), -f, tol); if f != std::f32::INFINITY { assert_almost_equal!(f, f.next(), tol); assert_almost_equal!(f.next(), f, tol); assert_almost_equal!(-f, (-f).prev(), tol); assert_almost_equal!((-f).prev(), -f, tol); } } } for &v in &[almost::F32_TOLERANCE, 1.0, std::f32::NAN, std::f32::INFINITY] { assert!(!almost::zero(v), "{} {:x}", v, v.to_bits()); assert!(!almost::zero(-v), "{} {:x}", v, v.to_bits()); } for &v in &[almost::F32_TOLERANCE.prev(), 0.0, std::f32::EPSILON, 0.0.next()] { assert!(almost::zero(v), "{} {:x}", v, v.to_bits()); assert!(almost::zero(-v), "{} {:x}", v, v.to_bits()); } }