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?
Asked
Active
Viewed 1,415 times
2 Answers
10
You can use the F# Powerpack which has a BigRational
(arbitrary precision rational numbers) type:
let r = (1N/2N) * (1N/3N) // 1/6

Gabe
- 84,912
- 12
- 139
- 238
-
Hi Gabe, is this something that's still viable, or do you know if its been replaced by new F# features? – JimDel Nov 25 '14 at 21:04
-
@JimDel: As far as I know, Powerpack is still the way to go. – Gabe Nov 26 '14 at 00:06
-
According to the [F# PowerPack archive on GitHub README](https://github.com/fsprojects/zzarchive-powerpack), BigRational is present in [F# support in Math.Net Numerics](http://numerics.mathdotnet.com/) – karmakaze Jan 04 '20 at 22:43
0
The BigRational
type has F# support in Math.Net Numerics according to the updated F# PowerPack archive on GitHub README.

karmakaze
- 34,689
- 1
- 30
- 32