Is there a way to convert a floating number to int in Julia? I'm trying to convert a floating point number to a fixed precision number with the decimal part represented as 8bit integer. In order to do this, I need to truncate just the decimal part of the number and I figured the best way to do this would be to subtract the converted integer of x from floating point x:
x = 1.23455
y = x - Int(x)
println(y)
y = 0.23455
I think you are looking for floor
:
julia> x = 1.23455
1.23455
julia> floor(x)
1.0
julia> y = x - floor(x)
0.23455000000000004