3 ms·
Not really, although I imagine this might become possible once 'const generics' stabilizes. Then you'd be able to define a generic type with a certain precision
by Thiez 8y ago
Not really, although I imagine this might become possible once 'const generics' stabilizes. Then you'd be able to define a generic type with a certain precision (of course you can do this today but you have to define a different type for different numbers of decimals). Overloading the arithmetic operators can be done. The only problem I see would be not having syntactic sugar for defining such a number, unlike integers and doubles.
- krick 8y agoActually, I have absolutely no idea, how it is represented internally. Shamefully, I'm so used to thinking that there are 8/16/32/64-bit signed/unsigned ints, IEEE-754 floats and bunch of other "basic" stuff, and pretty much anything more sophisticated is being done with those plus some union/record/ADT/pointer magic on top of it, that I'm entirely unable to imagine how introducing another fundamental data-type would work. Would Rust's compiler backend ever able to make it as "native" and efficient as floats? Would your typical Intel/AMD/Qualcomm processor even know how to deal with this stuff, or it would turn out as "efficient" as manual string-based arbitrary-precision calculations? And, regardless, is there any difference between how Rust compiler technology could represent it and how gcc could represent it?