I was trying to get my head around how invalid mathematical values are handled in Rust, so I thought I will have a look at what happens if I take the tangent of 90 degrees. What I didn't expect is that I will get a 'proper' value so when I run this code:
fn main() {
use std::f32;
for i in 89997..90003 {
let angle = (i as f32) / 1000.0;
println!("tan of {}: {}", angle, angle.to_radians().tan());
}
}
I get the following result:
tan of 89.997: 19124.42
tan of 89.998: 28665.936
tan of 89.999: 57208.06
tan of 90: -22877334
tan of 90.001: -57312.285
tan of 90.002: -28692.08
What is the meaning of -22877334 in this context?