Preferences

I wonder why they chose to represent rationals with subtracting one from the denominator. It makes human parsing of the value harder and in many case makes the implementation code slighter harder; for example the equality op need to increment both denominators before using them. I suspect such increment must be constantly be needed left and right?

I suspect it's to exclude a denominator of 0.
No, since they use an integer (Z) as the denominator. So their representation support having -1 (i.e 0) as the denominator.
Yes, this is mostly a leftover from initial versions that used a natural number as denominator. It doesn't seem to make a noticeable difference in performance though, since increments are a very basic operation.

I think leaving this in the article makes the non-zero denominator more explicit. It also allows easier adoption to other numeral systems :)

This item has no comments currently.

Keyboard Shortcuts

Story Lists

j
Next story
k
Previous story
Shift+j
Last story
Shift+k
First story
o Enter
Go to story URL
c
Go to comments
u
Go to author

Navigation

Shift+t
Go to top stories
Shift+n
Go to new stories
Shift+b
Go to best stories
Shift+a
Go to Ask HN
Shift+s
Go to Show HN

Miscellaneous

?
Show this modal