Re:C0, an Imperative Programming Language for Novice Compute...
by Avshalom on Wednesday October 18, 2017 @11:46AM
(#15500114)
division is not defined on the set of integers, you only have modular arithmetic.
[ Parent
| on HN ]
Re:C0, an Imperative Programming Language for Novice Compute...
by instruction-ptr on Wednesday October 18, 2017 @11:52AM
(#15500179)
See section 7 of http://www.cs.cmu.edu/~15122/handouts/02-ints.pdf
(As an aside nearly every language defines division on the set of integers this way so it’s not even like we’re making this up)
Re:C0, an Imperative Programming Language for Novice Compute...
by recursive on Wednesday October 18, 2017 @12:11PM
(#15500346)
It is defined and you can do it in C without using floats. On the other hand, even if you do use floats, arbitrary arithmetic is not invertible. In other words a / b * b isn't necessarily a, regardless of what types they are.
Re:C0, an Imperative Programming Language for Novice Compute...
by baby on Wednesday October 18, 2017 @12:14PM
(#15500384)
What do you mean division is not defined on the set of integers? Mathematically or programmatically? Because yes you have euclidean divisions which are divisions for the integers.
Re:C0, an Imperative Programming Language for Novice Compute...
by jameshart on Wednesday October 18, 2017 @12:05PM
(#15500301)
division is also not defined on the set of IEEE binary floating point numbers, you only have (well-defined) rounding.
For that matter, addition and subtraction aren't defined on the range of fixed-bit-width integers.