ERROR: InexactError: Int32(42.00000000000001)
@ Base .\float.jl:791
 top-level scope
Or for that matter, it seems like
0.14 has a bug with floating point math …
This is a known limitation with float point operations. There might be some degree of imprecision because the computer does not represent numbers exactly. You will find similar results in Python for example.
So is it safest to always use
Int32(round( math )) if an integer is expected?
I suspect it depends on the amount of precision you need. You could use
BigInt if you need more precision. But I am not really an expert at mitigating float point rounding errors. I think if you describe your needs, someone with more expertise might be able to provide sound guidance.
It seems like rational numbers might help with division, but that exhausts my knowledge.
round(Int32, math) is better.
For my error, it was just to go into an argument for an array initialization within a loop, e.g.
zeros(Int32( x[i] * 300 )) and when
0.14, it was not happy.
Gotcha. That might be OK if you are not testing exact equalities in your code. Perhaps you could
isapprox, but there might be other or better options for such cases.