How can I control FPU rounding mode?

Is there any way in Rust to control FPU rounding mode? C99 introduced fesetround, is there equivalent method in Rust?

I need it for my Numeric Analysys classes where we implement interval arithmetic.

If I compile example code using fesetround using clang, it looks like it just calls out to the function in the C standard library.

As such, you should be able to use FFI to call it. That said, I'd recommend testing to make sure it really does what it's supposed to do, and don't assume the result is necessarily portable.

It works for me. Maybe num crate could implement this. Only problem that I see is that rounding flags are defined as precompiler constants. LLVM seem to define them platform independent but I don't know how others do it.