Vector of Rational{Int64}


Does anyone know why the following …

rationalVector::Vector{Rational{Int64}} = [ (2//3), (5//8), (11//17), (44/101) ]
for rational in rationalVector
  println(rational)
end # for rational

… prints the following …

6004799503160661//9007199254740992
5//8
5828187753067701//9007199254740992
7847856776407993//18014398509481984

I had expected the code to print …

2//3
5//8
11//17
44//101

Code executed using Julia 1.8.3 in a Windows Command Prompt window.


(44/101) isn’t 44//101. The array was promoted to Float64s.

1 Like