mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-10-05 18:08:04 +03:00
A hack to always print .0 for non base 10 numbers.
This helps with copy-pasting values, as non base 10 literals are not overloaded.
This commit is contained in:
parent
1dd4bbd22c
commit
6e412ed32e
@ -73,7 +73,7 @@ fpPP opts bf =
|
||||
case bfSign num of
|
||||
Nothing -> "fpNaN"
|
||||
Just s
|
||||
| bfIsFinite num -> text (bfToString base fmt num)
|
||||
| bfIsFinite num -> text hacStr
|
||||
| otherwise ->
|
||||
case s of
|
||||
Pos -> "fpPosInf"
|
||||
@ -89,6 +89,7 @@ fpPP opts bf =
|
||||
AutoExponent -> f
|
||||
ForceExponent -> f <> forceExp
|
||||
|
||||
str = bfToString base fmt num
|
||||
fmt = addPrefix <> showRnd NearEven <>
|
||||
case useFPFormat opts of
|
||||
FloatFree e -> withExp e $ showFreeMin
|
||||
@ -96,6 +97,13 @@ fpPP opts bf =
|
||||
FloatFixed n e -> withExp e $ showFixed $ fromIntegral n
|
||||
FloatFrac n -> showFrac $ fromIntegral n
|
||||
|
||||
-- non-base 10 literals are not overloaded so we add an explicit
|
||||
-- .0 if one is not present.
|
||||
hacStr
|
||||
| base == 10 || elem '.' str = str
|
||||
| otherwise = case break (== 'p') str of
|
||||
(xs,ys) -> xs ++ ".0" ++ ys
|
||||
|
||||
|
||||
|
||||
-- | Make a literal
|
||||
|
@ -32,7 +32,7 @@ Specifies the format to use when showing floating point numbers:
|
||||
0x0.6
|
||||
0x1.234p4
|
||||
0x12.3
|
||||
0x12
|
||||
0x12.0
|
||||
0x1.2p4
|
||||
"-- Float Type-----------------------------------------------------------------"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user