Lemmy
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
io@piefed.blahaj.zone to Programmer Humor@programming.devEnglish · 1 day ago

NaN Posting

piefed.cdn.blahaj.zone

message-square
14
link
fedilink
445

NaN Posting

piefed.cdn.blahaj.zone

io@piefed.blahaj.zone to Programmer Humor@programming.devEnglish · 1 day ago
message-square
14
link
fedilink

https://mastodon.well.com/@rk/115533116416499294

alert-triangle
You must log in or # to comment.
  • ArbitraryValue@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    72
    ·
    edit-2
    1 day ago

    Things that are numbers:

    • a memory address
    • the letter B
    • an error encountered when trying to open a file
    • the concept of being false, as opposed to being true

    Things that are not numbers:

    • this particular floating-point number
    • marcos@lemmy.world
      link
      fedilink
      arrow-up
      4
      ·
      1 day ago
      >> typeof(NaN)
      <- "number"
      

      It’s valid for C too, but it will be either a double or a float.

      • zerofk@lemmy.zip
        link
        fedilink
        arrow-up
        2
        ·
        20 hours ago
        #include <cmath>
        #include <iostream>
        #include <numbers>
        
        int main()
        {
          decltype ( NAN ) f { std::numbers::pi };
          std::cout << f << std::endl;
        } 
        
        • marcos@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          20 hours ago

          Dude, after forcing -std=c++20, the compiler still can’t find a reference for std::ostream::operator<<(float)…

          Do I have to link with some non-standard library? There doesn’t seem to have any numbers.a included with gcc.

          • zerofk@lemmy.zip
            link
            fedilink
            arrow-up
            2
            ·
            edit-2
            20 hours ago

            Weird, it should be standard C++20. Hope are you invoking gcc?

            godbolt link: https://godbolt.org/z/6Tn4Kcjrs

            Edit: be sure to call g++, not gcc.

            • marcos@lemmy.world
              link
              fedilink
              arrow-up
              2
              ·
              17 hours ago

              Oh, that’s right, I was using gcc.

    • Arghblarg@lemmy.ca
      link
      fedilink
      arrow-up
      7
      arrow-down
      1
      ·
      1 day ago

      Things that are numbers

      …

      the concept of being false, as opposed to being true

      ? If your’re referring to the C language convention that anything nonzero is ‘true’… false itself is exactly zero. Zero is a number. Perhaps I miss something here?

      • ArbitraryValue@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        20
        ·
        1 day ago

        That’s what I’m saying.

        • Arghblarg@lemmy.ca
          link
          fedilink
          arrow-up
          4
          ·
          1 day ago

          Ah. OK. I re-read your comment :) Silly me.

  • 🇰 🌀 🇱 🇦 🇳 🇦 🇰 🇮 @pawb.social
    link
    fedilink
    English
    arrow-up
    29
    ·
    1 day ago

    accidentally double types the a and suddenly his program is baking flatbread

  • marcos@lemmy.world
    link
    fedilink
    arrow-up
    7
    ·
    1 day ago

    At least NaNs are different from each other and themselves.

    SQL’s null would like a word here.

  • fibojoly@sh.itjust.works
    link
    fedilink
    arrow-up
    12
    ·
    1 day ago

    That makes sense though. Two things can be “not number” yet be different.

    • Cevilia (she/they/…)@lemmy.blahaj.zone
      link
      fedilink
      English
      arrow-up
      5
      ·
      1 day ago

      But two things cannot be “not number” and be the same.

      • Kairos@lemmy.today
        link
        fedilink
        arrow-up
        2
        ·
        21 hours ago

        And they should still fail == because that’s the behavior of IEEE 754 numbers.

Programmer Humor@programming.dev

programmer_humor@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmer_humor@programming.dev

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 2.02K users / day
  • 4.28K users / week
  • 8.44K users / month
  • 19.3K users / 6 months
  • 1 local subscriber
  • 27.3K subscribers
  • 1.3K Posts
  • 32.6K Comments
  • Modlog
  • mods:
  • adr1an@programming.dev
  • Feyter@programming.dev
  • BurningTurtle@programming.dev
  • Pierre-Yves Lapersonne@programming.dev
  • BE: 0.19.13
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org