halogen-websocket-ipc-playzone/drop/Base64.purs

15 lines
339 B
Plaintext
Raw Normal View History

2024-03-14 01:10:18 +01:00
module Base64 where
import Prelude (($), (+), (/), (-))
import Data.Int (toNumber, floor)
import Data.Number ((%))
datasize2b64size :: Int -> Int
datasize2b64size v =
let x = toNumber v
remainder = x % 24.0
additional_chars = (x / 24.0) + (32.0 - remainder) / 8.0
base = x / 8.0
in floor $ base + additional_chars