How do you represent fraction in F# without the loss of precision?
Asked Answered
P

2

5

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?

Porcine answered 17/3, 2011 at 2:54 Comment(0)
P
10

You can use the F# Powerpack which has a BigRational (arbitrary precision rational numbers) type:

let r = (1N/2N) * (1N/3N) // 1/6
Purree answered 17/3, 2011 at 2:59 Comment(3)
Hi Gabe, is this something that's still viable, or do you know if its been replaced by new F# features?Stria
@JimDel: As far as I know, Powerpack is still the way to go.Purree
According to the F# PowerPack archive on GitHub README, BigRational is present in F# support in Math.Net NumericsArrearage
A
0

The BigRational type has F# support in Math.Net Numerics according to the updated F# PowerPack archive on GitHub README.

Arrearage answered 4/1, 2020 at 22:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.