Are the numerator and denominator stored as integers? Specifically, how are implemented the basic operations: sum, subtraction, multiplication, division?
How are rational numbers implemented in Julia
299 views Asked by Alejandro Arcila At
2
https://github.com/JuliaLang/julia/blob/248bbf6d61b643d0101bf96093cd7621e5bcf477/base/rational.jl#L9-L15
the code is fairly readable, in short:
means that both numerator and denominator have the same type, and that type is
<: Integer.if you want to know how some operations are implemented, try running this in your REPL:
it should bring you to https://github.com/JuliaLang/julia/blob/248bbf6d61b643d0101bf96093cd7621e5bcf477/base/rational.jl#L285