Skip to content

Commit

Permalink
use ShortByteString to hold zeros and named 'primBBounded word64Dec'
Browse files Browse the repository at this point in the history
  • Loading branch information
BebeSparkelSparkel committed Jan 15, 2024
1 parent 90135d1 commit 2184529
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions Data/ByteString/Builder/RealFloat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ module Data.ByteString.Builder.RealFloat
, generic
) where

import Data.ByteString.Builder.Internal (Builder, byteString)
import Data.ByteString.Builder.Internal (Builder, shortByteString)
import qualified Data.ByteString.Builder.RealFloat.Internal as R
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString.Builder.RealFloat.F2S as RF
import qualified Data.ByteString.Builder.RealFloat.D2S as RD
import qualified Data.ByteString.Builder.Prim as BP
import qualified Data.ByteString.Short as BS
import GHC.Float (roundTo)
import GHC.Word (Word64)
import GHC.Show (intToDigit)
Expand Down Expand Up @@ -265,18 +265,18 @@ showStandard m e prec =
| e <= 0
-> string7 "0."
<> zeros (-e)

Check failure on line 267 in Data/ByteString/Builder/RealFloat.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 8.2)

• Variable not in scope: (<>) :: Builder -> Builder -> t0
<> BP.primBounded BP.word64Dec m
<> buildDigits m

Check failure on line 268 in Data/ByteString/Builder/RealFloat.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 8.2)

• Variable not in scope: (<>) :: t0 -> Builder -> Builder
| e >= olength
-> BP.primBounded BP.word64Dec m
-> buildDigits m
<> zeros (e - olength)

Check failure on line 271 in Data/ByteString/Builder/RealFloat.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 8.2)

• Variable not in scope: (<>) :: Builder -> Builder -> t1
<> string7 ".0"

Check failure on line 272 in Data/ByteString/Builder/RealFloat.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 8.2)

• Variable not in scope: (<>) :: t1 -> Builder -> Builder
| otherwise -> let
wholeDigits = m `div` (10 ^ (olength - e))
fractDigits = m `mod` (10 ^ (olength - e))
in BP.primBounded BP.word64Dec wholeDigits
in buildDigits wholeDigits
<> char7 '.'

Check failure on line 277 in Data/ByteString/Builder/RealFloat.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 8.2)

• Variable not in scope: (<>) :: Builder -> Builder -> t3
<> zeros (olength - e - R.decimalLength17 fractDigits)

Check failure on line 278 in Data/ByteString/Builder/RealFloat.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 8.2)

• Variable not in scope: (<>) :: t3 -> Builder -> t2
<> BP.primBounded BP.word64Dec fractDigits
<> buildDigits fractDigits

Check failure on line 279 in Data/ByteString/Builder/RealFloat.hs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, 8.2)

• Variable not in scope: (<>) :: t2 -> Builder -> Builder
Just p
| e >= 0 ->
let (ei, is') = roundTo 10 (p' + e) ds
Expand All @@ -296,5 +296,6 @@ showStandard m e prec =
ds = digits m
digitsToBuilder = fmap (char7 . intToDigit)

zeros n = byteString $ BC.take n $ BC.replicate 308 '0'
zeros n = shortByteString $ BS.take n $ BS.replicate 308 48
olength = R.decimalLength17 m
buildDigits = BP.primBounded BP.word64Dec

0 comments on commit 2184529

Please sign in to comment.