kuuhana
  • Communities
  • Multi-communities
  • Support Lemmy
  • Search
  • Login
  • Sign Up
Programmer Humor@programming.devbyio@piefed.blahaj.zone
7 months

NaN Posting

piefed.cdn.blahaj.zone English

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

14
    You must log in or register to comment.

    • ArbitraryValue@sh.itjust.worksEnglish
      7 months

      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
        • Arghblarg@lemmy.ca
          7 months

          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.worksEnglish
              7 months

              That’s what I’m saying.

                • Arghblarg@lemmy.ca
                  7 months

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

              • marcos@lemmy.world
                7 months
                >> typeof(NaN)
                <- "number"
                

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

                  • zerofk@lemmy.zip
                    7 months
                    #include <cmath>
                    #include <iostream>
                    #include <numbers>
                    
                    int main()
                    {
                      decltype ( NAN ) f { std::numbers::pi };
                      std::cout << f << std::endl;
                    } 
                    
                      • marcos@lemmy.world
                        7 months

                        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
                            7 months

                            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
                                7 months

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

                      • 🇰 🌀 🇱 🇦 🇳 🇦 🇰 🇮 @pawb.socialEnglish
                        7 months

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

                        • fibojoly@sh.itjust.works
                          7 months

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

                            • Cevilia (they/she/…)@lemmy.blahaj.zoneEnglish
                              7 months

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

                                • Kairos@lemmy.today
                                  7 months

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

                              • marcos@lemmy.world
                                7 months

                                At least NaNs are different from each other and themselves.

                                SQL’s null would like a word here.

                                Programmer Humor@programming.dev

                                programmer_humor@programming.dev

                                Subscribe from remote instance

                                Create post

                                Report community

                                Modlog
                                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

                                This community is visible to everyone.

                                • 36 users / Day
                                • 262 users / Week
                                • 276 users / Month
                                • 14.5K users / 6 months
                                • 2.33K posts
                                • 89.8K comments
                                • 2 local subscribers
                                • 31.9K subscribers
                                • UI: 1.0.0-beta.0
                                • BE: 1.0.0-alpha.20
                                • Modlog
                                • Instances
                                • Docs
                                • Code
                                • join-lemmy.org