module Data.Text.Internal.Builder.Int.Digits (digits, Base(..), base10, base16) where
import Data.Bits (finiteBitSize)
import Data.ByteString.Char8 (ByteString, pack)
digits :: ByteString
digits :: ByteString
digits = String -> ByteString
pack
String
"0001020304050607080910111213141516171819\
\2021222324252627282930313233343536373839\
\4041424344454647484950515253545556575859\
\6061626364656667686970717273747576777879\
\8081828384858687888990919293949596979899"
data Base = Base
{ Base -> Word
base :: !Word
, Base -> Integer
maxWord :: !Integer
, Base -> Int
maxDigits :: !Int
}
base10 :: Base
base10 :: Base
base10 = Base
{ base :: Word
base = Word
10
, maxWord :: Integer
maxWord = Integer
10 Integer -> Int -> Integer
forall a b. (Num a, Integral b) => a -> b -> a
^ Int
maxDigits10
, maxDigits :: Int
maxDigits = Int
maxDigits10
} where
maxDigits10 :: Int
maxDigits10 = Word -> Int
forall b. FiniteBits b => b -> Int
finiteBitSize (Word
0 :: Word) Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
3 Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
10
base16 :: Base
base16 :: Base
base16 = Base
{ base :: Word
base = Word
16
, maxWord :: Integer
maxWord = Integer
16 Integer -> Int -> Integer
forall a b. (Num a, Integral b) => a -> b -> a
^ Int
maxDigits16
, maxDigits :: Int
maxDigits = Int
maxDigits16
} where
maxDigits16 :: Int
maxDigits16 = Word -> Int
forall b. FiniteBits b => b -> Int
finiteBitSize (Word
0 :: Word) Int -> Int -> Int
forall a. Integral a => a -> a -> a
`div` Int
4