ekmett / ekmett/bytes

Use `GHC.Float` functions rather than C code where possible

Open
#57 0 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Haskell
Stars
23
Forks
13
PR merge metrics
No merged PRs in 30d

Description

Currently, `bytes` defines functions to convert from floating-point values to word values (and vice versa) in [`i2d.c`](https://github.com/ekmett/bytes/blob/6dcab34cd12f827bd1f6d7a508c960d87c2452fc/cbits/i2d.c). However, in `base-4.10.0.0` (GHC 8.2) and later, the `GHC.Float` module offers equivalent functionality in the `castDoubleToWord64` function, as well as its cohorts. As far as I can tell, these functions are bit-for-bit compatible, although I'd have to stare at the [corresponding Cmm code](https://gitlab.haskell.org/ghc/ghc/-/blob/7045b7831cae974ed3a96aa8246ec93846aa868b/libraries/base/cbits/CastFloatWord.cmm#L10-69) to know for sure.

If we used the `GHC.Float` functions instead, we would no longer need to link against C code on recent versions of GHC. This has come up elsewhere in https://github.com/ekmett/bits/pull/7#issuecomment-962594421.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.