How do you represent fraction in F# without the loss of precision?
-
26-10-2019 - |
Question
What is best way to represent fractions in F#? Haskell and Racket have convinient way to represent ratios. Is there a data type in F# to represent ratios?
Solution
You can use the F# Powerpack which has a BigRational
(arbitrary precision rational numbers) type:
let r = (1N/2N) * (1N/3N) // 1/6
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow