GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

# Ad-hoc userland implementation of comparison ops set '<0 { != 0 (& 9223372036854775808 (get args 0)) } set '< { <0 (- (get args 0) (get args 1)) } set '>= { ! (< (get args 0) (get args 1)) } set '<= { # No, these variable names aren't great inset args '(_<=_x _<=_y) || (= _<=_x _<=_y) (< _<=_x _<=_y) } set '> { ! (<= (get args 0) (get args 1)) } print (< 4 5) sp (<= 4 5) sp (> 4 5) sp (>= 4 5) ln print (< 9 2) sp (<= 9 2) sp (> 9 2) sp (>= 9 2) ln print (< 7 7) sp (<= 7 7) sp (> 7 7) sp (>= 7 7) ln

Download link

https://files.mastodon.social/media_attachments/files/114/310/146/229/037/142/original/4c4a40581abf4936.png

Notices where this attachment appears

  1. Embed this notice
    mcc (mcc@mastodon.social)'s status on Friday, 11-Apr-2025 03:06:43 JST mcc mcc
    in reply to

    Anyway, I like testing things before I use them, so after implementing my "if" and "while" I decide to write a simple Fizzbuzz program. This causes me to immediately realize—

    I FORGOT TO IMPLEMENT > AND <

    I just forgot!! Fortunately I *did* include bit arithmetic ops, so I implement <, >, <=, >= in userland as well, by testing bit (1<<63) as a proxy for 2's compliment negative. This is actually a little worrisome. I'm not sure if this code truly "works" or if I'm just leveraging UB in Rust.

    In conversation about 2 months ago from mastodon.social permalink
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.