Division and Modulo in Babel-17

The upcoming Babel-17 v0.21 will only know integer numbers, no real numbers; but  real numbers in form of interval arithmetic will be part of the next version of Babel-17.

Therefore, what should for example


evaluate to? Because Babel-17 currently only has integers, the result 1 seems to make sense. But factoring in the fact that eventually, there will be real numbers in Babel-17, this could be a major source of confusion, because the similar expression


would not evaluate to 1, but to 1.75 .

Therefore two new binary operators are introduced in Babel-17, “div” and “mod” which will denote euclidean division and modulo operations. Therefore the following will evaluate to true in later versions of Babel-17:

7 / 4 == 7.0 / 4.0 == 7 / 4.0 == 7.0 / 4 == 1.75  &

7 div 4 == 1 & 7 mod 4 == 3

In Babel-17 v0.21, u/v will always result in a DomainError for integers u and v.
The operator “%” will vanish. Its function is taken over by the new operator “mod”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: