I am implementing the CORDIC algorithm for the sin
trigonometric function. In order to do this, I need to hardcode/calculate a bunch of arctangent values. Right
This answer was written for Rust 0.12.0 and doesn't apply to Rust 1.x.
You can use the to_string function in std::f32
(not to be confused with the to_string method):
fn main() {
println!("{}", std::f32::to_string(unsafe { std::mem::transmute::(1) }));
println!("{}", std::f32::to_string(unsafe { std::mem::transmute::(16) }));
println!("{}", std::f32::to_string(std::f32::MIN_POS_VALUE));
println!("{}", std::f32::to_string(std::f32::MAX_VALUE));
println!("{}", std::f32::to_string(std::f32::consts::PI));
}
Output:
0.00000000000000000000000000000000000000000000140129852294921875
0.000000000000000000000000000000000000000000022420775890350341796875
0.000000000000000000000000000000000000011754944324493408203125
340282368002860660002286082464244022240
3.1415927410125732421875