Template:Hex
This template shows the exact value of a number of type float.
The significand is given in hexadecimal format, which, apart from the sign, consists of a fixed "1.
", followed by 13 hexadecimal characters.
Denormal numbers are shown in normalized format, not in internal format, but without inherently zero digits.
No distinction is made between 0 and -0.
For numbers of type integer which are not exactly representable as float the integer is rounded to float. If an integer just below 2^n is rounded to 2^n the result is shown in the form 2*2^(n-1), thus giving the exponent the value it would have in an exact floating-point representation (which would require up to 10 bits more, hence up to three hexadecimal digits more).
See also Manual:Floating-point errors in expr parser function.
Examples
[edit]{{hex}}
→{{hex|a}}
→a
{{hex|0}}
→0
{{hex|-0}}
→0
{{hex|1/7}}
→1.2492492492492hex*2^-3
{{hex|-2/3}}
→-1.5555555555555hex*2^-1
{{hex|123}}
→1.ec00000000000hex*2^6
{{hex|.0123}}
→1.930be0ded288dhex*2^-7
{{hex|1+2^-52}}
→1.0000000000001hex*2^0
{{hex|1.0000000000000002}}
→1.0000000000001hex*2^0
{{hex|1+2e-16}}
→1.0000000000001hex*2^0
{{hex|-1e309}}
→-INF
{{hex|1e309}}
→INF
{{hex|1e308}}
→1.1ccf385ebc8a0hex*2^1023
{{hex|1e307}}
→1.c7b1f3cac7433hex*2^1019
{{hex|1e306}}
→1.6c8e5ca239029hex*2^1016
{{hex|1e305}}
→1.23a516e82d9bahex*2^1013
{{hex|1e304}}
→1.d2a1be4048f90hex*2^1009
{{hex|1e303}}
→1.754e31cd072dahex*2^1006
{{hex|1e302}}
→1.2aa4f4a405be2hex*2^1003
{{hex|1e301}}
→1.ddd4baa009303hex*2^999
{{hex|1e300}}
→1.7e43c8800759chex*2^996
{{hex|1e299}}
→1.31cfd3999f7b0hex*2^993
{{hex|1e298}}
→1.e94c85c298c4chex*2^989
{{hex|1e297}}
→1.87706b0213d0ahex*2^986
{{hex|1e296}}
→1.3926bc01a973bhex*2^983
{{hex|1e295}}
→1.f50ac6690f1f8hex*2^979
{{hex|1e294}}
→1.90d56b873f4c7hex*2^976
{{hex|1e293}}
→1.40aabc6c32a38hex*2^973
{{hex|1e292}}
→1.008896bcf54fahex*2^970
{{hex|1e-308}}
→1.cc359e067a348hex*2^-1024
{{hex|1e-309}}
→1.702ae4d1fb5ehex*2^-1027
{{hex|1e-310}}
→1.2688b70e62bhex*2^-1030
{{hex|1e-311}}
→1.d74124e3d1hex*2^-1034
{{hex|1e-312}}
→1.7900ea4fd8hex*2^-1037
{{hex|1e-313}}
→1.2d9a550cchex*2^-1040
{{hex|1e-314}}
→1.e2908814hex*2^-1044
{{hex|1e-315}}
→1.820d39ahex*2^-1047
{{hex|1e-316}}
→1.34d761hex*2^-1050
{{hex|1e-317}}
→1.ee257hex*2^-1054
{{hex|1e-318}}
→1.8b510hex*2^-1057
{{hex|1e-319}}
→1.3c40hex*2^-1060
{{hex|1e-320}}
→1.fa0hex*2^-1064
{{hex|1e-321}}
→1.94hex*2^-1067
{{hex|1e-322}}
→1.4hex*2^-1070
{{hex|1e-323}}
→1.0hex*2^-1073
{{hex|1e-323/2}}
→1.hex*2^-1074
{{hex|1e-323/3}}
→1.hex*2^-1074
{{hex|1e-323/4}}
→0
{{hex|.{{loop|323|0}}25}}
→1.hex*2^-1074
{{hex|.{{loop|323|0}}24}}
→0
{{hex|1000000e-324}}
→0
{{hex|1.71*2^-1021}}
→1.b5c28f5c28f5chex*2^-1021
{{hex|1.71*2^-1022}}
→1.b5c28f5c28f5chex*2^-1022
{{hex|1.71*2^-1023}}
→1.b5c28f5c28f5chex*2^-1023
{{hex|1.71*2^-1024}}
→1.b5c28f5c28f5chex*2^-1024
{{hex|1.71*2^-1025}}
→1.b5c28f5c28f60hex*2^-1025
{{hex|1.71*2^-1064}}
→1.b5chex*2^-1064
{{hex|1.71*2^-1065}}
→1.b60hex*2^-1065
{{hex|1.71*2^-1066}}
→1.b6hex*2^-1066
{{hex|1.71*2^-1067}}
→1.b6hex*2^-1067
{{hex|1.71*2^-1068}}
→1.b4hex*2^-1068
{{hex|1.71*2^-1069}}
→1.b8hex*2^-1069
{{hex|1.71*2^-1070}}
→1.bhex*2^-1070
{{hex|1.71*2^-1071}}
→1.chex*2^-1071
{{hex|1.71*2^-1072}}
→1.chex*2^-1072
{{hex|1.71*2^-1073}}
→1.8hex*2^-1073
{{hex|1.71*2^-1074}}
→1.0hex*2^-1073
{{hex|3*2^-1074}}
→1.8hex*2^-1073
{{hex|2*2^-1074}}
→1.0hex*2^-1073
{{hex|1*2^-1074}}
→1.hex*2^-1074
Numbers of type integer which are not exactly representable as float:
{{hex|trunc(2^62-512)+trunc511}}
→2hex*2^61