logoalt Hacker News

entaloneralietoday at 4:05 AM2 repliesview on HN

This is amazing! I love seeing FRACTRAN-shaped things on the homepage :) This reminds me of how 1-bit stacks are encoded in binary:

A stack of zeros and ones can be encoded in a single number by keeping with bit-shifting and incrementing.

    Pushing a 0 onto the stack is equivalent to doubling the number.
    Pushing a 1 is equivalent to doubling and adding 1.
    Popping is equivalent to dividing by 2, where the remainder is the number.
I use something not too far off for my daily a programming based on a similar idea:

Rejoice is a concatenative programming language in which data is encoded as multisets that compose by multiplication. Think Fractran, without the rule-searching, or Forth without a stack.

https://wiki.xxiivv.com/site/rejoice


Replies

SeanSullivan86today at 2:29 PM

Wouldn't you also need to keep track of the stack's size, to know if there are leading zeros?

show 1 reply
StilesCrisistoday at 11:23 AM

Did you just explain base-2 numbers on the HN forums as if it were novel?

show 4 replies