size_of and align_of
size_of and align_of
Posted Jul 28, 2024 20:10 UTC (Sun) by tialaramex (subscriber, #21167)In reply to: size_of and align_of by NYKevin
Parent article: Rust 1.80.0 released
Basically instead of 4, a single byte with the pattern 00000100 in it, my four is: Two num::BigUints (a numerator and denominator) to form a rational magnitude, then a sign flag, a sum type which says whether we're also multiplying this by a fixed irrational value, and the potentially complicated arithmetic (with cached state, potentially very large) for the said irrational value if we are.
I would like to be able for the type of this data structure to provide something similar to a constant like FOUR and ZERO rather than (as I do in the current prototype) making such values each time they're needed.
This data structure is of course horribly unwieldy as a replacement for i32 or f64 - but it's perfectly reasonable for a desktop calculator type application, where the performance loss is more than amply compensated by knowing when there's an exact answer or it's in terms of a well known irrational such as Pi or e.
