Bug 224326

Summary: double subnormals are not well printed on printing with printf (and friends)
Product: Base System Reporter: Luis Colorado <luiscoloradourcola>
Component: miscAssignee: freebsd-bugs mailing list <bugs>
Status: New ---    
Severity: Affects Many People    
Priority: ---    
Version: 11.0-STABLE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
program run to get the expected and obtained output.
none
program to display correct values (except for rounding errors) none

Description Luis Colorado 2017-12-13 20:15:16 UTC
Created attachment 188809 [details]
program run to get the expected and obtained output.

subnormals are not recognized as such in doubles (they are in float) and long double.  I cannot do a make update to get the last version of the libc, as I'm in a Tier 2 (raspberry pi) architecture.  I'm running 11.0-STABLE.  I get this output for a program that consists in dividing by two a normalized number until I get zero:  (only the four first numbers are normalized)
(wrong output, expected follows)

0x0040000000000000 1.7800590868057611e-307 (ok, but normalized)
0x0030000000000000 8.9002954340288055e-308 (ok, but normalized)
0x0020000000000000 4.4501477170144028e-308 (ok, but normalized)
0x0010000000000000 2.2250738585072014e-308 (ok, but normalized)
0x0008000000000000 1.668805393880401e-308 (from here on, all are incorrect)
0x0004000000000000 1.3906711615670009e-308
0x0002000000000000 1.2516040454103008e-308
0x0001000000000000 1.1820704873319507e-308
0x0000800000000000 1.1473037082927757e-308
0x0000400000000000 1.1299203187731882e-308
0x0000200000000000 1.1212286240133944e-308
0x0000100000000000 1.1168827766334976e-308
0x0000080000000000 1.1147098529435491e-308
0x0000040000000000 1.1136233910985749e-308
0x0000020000000000 1.1130801601760878e-308
0x0000010000000000 1.1128085447148442e-308
0x0000008000000000 1.1126727369842225e-308
0x0000004000000000 1.1126048331189116e-308
0x0000002000000000 1.1125708811862561e-308
0x0000001000000000 1.1125539052199284e-308
0x0000000800000000 1.1125454172367646e-308
0x0000000400000000 1.1125411732451826e-308
0x0000000200000000 1.1125390512493917e-308
0x0000000100000000 1.1125379902514962e-308
0x0000000080000000 1.1125374597525484e-308
0x0000000040000000 1.1125371945030746e-308
0x0000000020000000 1.1125370618783376e-308
0x0000000010000000 1.1125369955659692e-308
0x0000000008000000 1.1125369624097849e-308
0x0000000004000000 1.1125369458316928e-308
0x0000000002000000 1.1125369375426468e-308
0x0000000001000000 1.1125369333981237e-308
0x0000000000800000 1.1125369313258622e-308
0x0000000000400000 1.1125369302897314e-308
0x0000000000200000 1.1125369297716661e-308
0x0000000000100000 1.1125369295126334e-308
0x0000000000080000 1.112536929383117e-308
0x0000000000040000 1.1125369293183589e-308
0x0000000000020000 1.1125369292859798e-308
0x0000000000010000 1.1125369292697902e-308
0x0000000000008000 1.1125369292616955e-308
0x0000000000004000 1.1125369292576481e-308
0x0000000000002000 1.1125369292556244e-308
0x0000000000001000 1.1125369292546125e-308
0x0000000000000800 1.1125369292541066e-308
0x0000000000000400 1.1125369292538537e-308
0x0000000000000200 1.1125369292537272e-308
0x0000000000000100 1.1125369292536639e-308
0x0000000000000080 1.1125369292536323e-308
0x0000000000000040 1.1125369292536165e-308
0x0000000000000020 1.1125369292536086e-308
0x0000000000000010 1.1125369292536046e-308
0x0000000000000008 1.1125369292536027e-308
0x0000000000000004 1.1125369292536017e-308
0x0000000000000002 1.1125369292536012e-308
0x0000000000000001 1.1125369292536009e-308

while expected behaviour is:

0x0040000000000000 1.7800590868057611e-307
0x0030000000000000 8.9002954340288055e-308
0x0020000000000000 4.4501477170144028e-308
0x0010000000000000 2.2250738585072014e-308
0x0008000000000000 1.1125369292536007e-308
0x0004000000000000 5.5626846462680035e-309
0x0002000000000000 2.7813423231340017e-309
0x0001000000000000 1.3906711615670009e-309
0x0000800000000000 6.9533558078350043e-310
0x0000400000000000 3.4766779039175022e-310
0x0000200000000000 1.7383389519587511e-310
0x0000100000000000 8.6916947597937554e-311
0x0000080000000000 4.3458473798968777e-311
0x0000040000000000 2.1729236899484389e-311
0x0000020000000000 1.0864618449742194e-311
0x0000010000000000 5.4323092248710971e-312
0x0000008000000000 2.7161546124355486e-312
0x0000004000000000 1.3580773062177743e-312
0x0000002000000000 6.7903865310888714e-313
0x0000001000000000 3.3951932655444357e-313
0x0000000800000000 1.6975966327722179e-313
0x0000000400000000 8.4879831638610893e-314
0x0000000200000000 4.2439915819305446e-314
0x0000000100000000 2.1219957909652723e-314
0x0000000080000000 1.0609978954826362e-314
0x0000000040000000 5.3049894774131808e-315
0x0000000020000000 2.6524947387065904e-315
0x0000000010000000 1.3262473693532952e-315
0x0000000008000000 6.631236846766476e-316
0x0000000004000000 3.315618423383238e-316
0x0000000002000000 1.657809211691619e-316
0x0000000001000000 8.289046058458095e-317
0x0000000000800000 4.1445230292290475e-317
0x0000000000400000 2.0722615146145237e-317
0x0000000000200000 1.0361307573072619e-317
0x0000000000100000 5.1806537865363094e-318
0x0000000000080000 2.5903268932681547e-318
0x0000000000040000 1.2951634466340773e-318
0x0000000000020000 6.4758172331703867e-319
0x0000000000010000 3.2379086165851934e-319
0x0000000000008000 1.6189543082925967e-319
0x0000000000004000 8.0947715414629834e-320
0x0000000000002000 4.0473857707314917e-320
0x0000000000001000 2.0236928853657458e-320
0x0000000000000800 1.0118464426828729e-320
0x0000000000000400 5.0592322134143646e-321
0x0000000000000200 2.5296161067071823e-321
0x0000000000000100 1.2648080533535912e-321
0x0000000000000080 6.3240402667679558e-322
0x0000000000000040 3.1620201333839779e-322
0x0000000000000020 1.5810100666919889e-322
0x0000000000000010 7.9050503334599447e-323
0x0000000000000008 3.9525251667299724e-323
0x0000000000000004 1.9762625833649862e-323
0x0000000000000002 9.8813129168249309e-324
0x0000000000000001 4.9406564584124654e-324
Comment 1 Luis Colorado 2017-12-14 20:49:56 UTC
Created attachment 188840 [details]
program to display correct values (except for rounding errors)

This is a simple program I wrote to get the expected values (compared also with glibc output, they differ in the two less significant digits at position 17)