• ArbitraryValue@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    66
    ·
    edit-2
    13 hours 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
      2
      ·
      edit-2
      8 hours 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
        ·
        3 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
          ·
          3 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.

    • Arghblarg@lemmy.ca
      link
      fedilink
      arrow-up
      7
      arrow-down
      1
      ·
      13 hours 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?