4 ms·
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 c
by entaloneralie 6mo ago
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 https://wiki.xxiivv.com/site/rejoice
- StilesCrisis 6mo agoDid you just explain base-2 numbers on the HN forums as if it were novel?
- nyeah 6mo agoIt's dry humor?
- lioeters 6mo agoYou missed the part where the number is being used as a 1-bit stack. They never claimed novelty, it's just a neat technique that might be unfamiliar to most people.
- entaloneralie 6mo agoI never claimed it was novel, chill.
- mackeye 6mo agoadding a zero to the left of a binary integer doesn't double it
- SeanSullivan86 6mo agoWouldn't you also need to keep track of the stack's size, to know if there are leading zeros?
- entaloneralie 6mo agoFor trailing zeros yeah, or if you care for stack overflow/underflow. Here's a few primitives if you wanna try it out: https://paste.sr.ht/~rabbits/cd2369cc7c72bfad0fcd83e2768209515fb019e4 https://paste.sr.ht/~rabbits/cd2369cc7c72bfad0fcd83e27682095...
- gowld 6mo agoHave I got news for you! https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts