Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are f64 types represented in 32 bit machines in Rust?

Tags:

types

rust

I just realized we can use f64 types even in a 32 bit machines with a bit of a performance trade-off. But, how is this achieved in Rust? Are two f32 types bundled together as a makeshift f64 type? Or something else going on behind the scenes?

Can someone explain how this is done without digging too deep into rust internals? (I'm still very new to Rust).

like image 225
Chakravarthy Raghunandan Avatar asked Dec 29 '25 21:12

Chakravarthy Raghunandan


1 Answers

They're represented in exactly the same way they're represented on a 64-bit machine; they're a hardware feature going back to the math co-processor for the 386, which was released somewhere around 1987.

Floats have nothing to do with the bitness of the machine.

The actual binary-level representation is documented exhaustively in other places, like the Wikipedia page on the Double-precision floating-point format.

like image 184
DK. Avatar answered Jan 01 '26 11:01

DK.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!