What is the most appropriate method to produce 2pi
in single precision? Do we need to explicitly convert from the double precision result?
I have geometric algorithms with angles that need to do 2pi - theta
and this is creating some type instabilities in single precision when theta is single
So my question is: is there a method to convert the irrational pi to a single precision float directly?
Float32(pi)
Yes, I guess that is the best option :smile:
there's always
julia> 2f0π
6.2831855f0
cool trick too :smile:
but in this case I need to be generic with a type T(pi)
inside a function
You may be interested in ChangePrecision.jl
@Júlio Hoffimann and @Fredrik Ekre would you mind if this was moved to #helpdesk (published)?
Not at all :smile:
This topic was moved here from #helpdesk > 2pi as Float32 by Mason Protter
Last updated: Nov 22 2024 at 04:41 UTC