SPIRV-Tools/source/util
Neil Roberts 57a2441791 hex_float: Use max_digits10 for the float precision
CPPreference.com has this description of digits10:

“The value of std::numeric_limits<T>::digits10 is the number of
 base-10 digits that can be represented by the type T without change,
 that is, any number with this many significant decimal digits can be
 converted to a value of type T and back to decimal form, without
 change due to rounding or overflow.”

This means that any number with this many digits can be represented
accurately in the corresponding type. A change in any digit in a
number after that may or may not cause it a different bitwise
representation. Therefore this isn’t necessarily enough precision to
accurately represent the value in text. Instead we need max_digits10
which has the following description:

“The value of std::numeric_limits<T>::max_digits10 is the number of
 base-10 digits that are necessary to uniquely represent all distinct
 values of the type T, such as necessary for
 serialization/deserialization to text.”

The patch includes a test case in hex_float_test which tries to do a
round-robin conversion of a number that requires more than 6 decimal
places to be accurately represented. This would fail without the
patch.

Sadly this also breaks a bunch of other tests. Some of the tests in
hex_float_test use ldexp and then compare it with a value which is not
the same as the one returned by ldexp but instead is the value rounded
to 6 decimals. Others use values that are not evenly representable as
a binary floating fraction but then happened to generate the same
value when rounded to 6 decimals. Where the actual value didn’t seem
to matter these have been changed with different values that can be
represented as a binary fraction.
2018-04-03 12:53:10 -04:00
..
bit_stream.cpp Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
bit_stream.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
bitutils.h Add barrier instructions validation pass 2018-02-05 13:14:55 -05:00
hex_float.h hex_float: Use max_digits10 for the float precision 2018-04-03 12:53:10 -04:00
huffman_codec.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
ilist_node.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
ilist.h Change merge return pass to handle structured cfg. 2018-03-19 13:49:04 -04:00
move_to_front.h Fixed harmless uninit var warning 2018-01-31 17:49:01 -05:00
parse_number.cpp Re-format source tree - NFC. 2017-11-27 14:31:49 -05:00
parse_number.h Re-format files in source, source/opt, source/util, source/val and tools. 2017-11-08 14:03:08 -05:00
string_utils.cpp Added option --preserve-numeric-ids to tools/spirv-as 2017-04-13 14:13:33 -04:00
string_utils.h Validator checks if operands require extension 2017-03-14 13:39:43 -04:00
timer.cpp Add --time-report to spirv-opt 2018-03-20 21:30:06 -04:00
timer.h Add --time-report to spirv-opt 2018-03-20 21:30:06 -04:00