Integer overflow
Integer overflow
Posted Apr 30, 2013 9:11 UTC (Tue) by etienne (guest, #25256)In reply to: Integer overflow by k8to
Parent article: A taste of Rust
I wonder if a language exists which separate "data" and "counter" variables, and associates every "data" with a unit - considering counters do not tend to overflow.
When a "data" overflow, it would then change the unit to something more appropriate.
For instance, if a variable contains "300 millimetres" and I multiply it by 10^9, the resulting variable would not contain 0x2BA7DEF3000 millimetres but 300000 meters.
Obviously it can be bad in some rare cases, but it would also have a lot of advantages: you can compare "data" variables in different compatible units (miles and kilometres, degree Fahrenheit and Celsius, joules and calories...) and it could deduce the unit of calculus (divide miles by hours and compare it to meters per second) and flags errors (compare kilowatt per hours to Amperes)...
Posted Apr 30, 2013 13:43 UTC (Tue)
by mathstuf (subscriber, #69389)
[Link]
Posted May 1, 2013 15:03 UTC (Wed)
by dark (guest, #8483)
[Link]
Integer overflow
The first part is basically what floating point math is :)
Integer overflow