soc.octade.net is a Fediverse instance that uses the ActivityPub protocol. In other words, users at this host can communicate with people that use software like Mastodon, Pleroma, Friendica, etc. all around the world.

This server runs the snac software and there is no automatic sign-up process.

Admin email
social@octade.net

Search results for tag #c

[?]Wayne Werner » 🌐
@ketmorco@fosstodon.org

Hey friends!

is back today - I'm going to be chatting very low level computing today and how it all relates to software as it's written today. How things are the same and how things are different!

Join me now at twitch.tv/srilyk

It won't be a deep dive, but I'll be touching on and

    screwlisp boosted

    [?]Vassil Nikolov | Васил Николов » 🌐
    @vnikolov@ieji.de

    More subtlety with arbitrary run-time precision (caveat programmator):

    $ clisp
    [1]> (defun e () "Return the value of e as a `long-float'." (exp 1L0))
    E
    [2]> (setf (long-float-digits) (* 16 (long-float-digits)))
    1024
    [3]> (expt (e) (* pi (0L0 1L0)))
    (-1.0L0 -7.845150826357264567L-20) ;Mathematically, a real number, of course.

    ;; Hmmm, too inaccurate.

    [4]> (integer-decode-float (imagpart *))
    13347832460223031479 ;
    -127 ;
    -1

    ;; Too inaccurate indeed.

    ;; Do you notice what Puck did?

    [5]> (e)
    2.7182818284590452354L0

    [6]> (describe #'e)

    #<FUNCTION E NIL "Return the value of e as a `long-float'." (DECLARE (SYSTEM::IN-DEFUN E)) (BLOCK E (EXP 1.0L0))> is an interpreted function.
    Argument list: ()
    Documentation: Return the value of e as a `long-float'.

    ;; Not compiled, by the way, not that it matters here.

    ;;; Take two:

    $ clisp
    [1]> (setf (long-float-digits) (* 16 (long-float-digits)))
    1024
    [2]> (defun e () "Return the value of e as a `long-float'." (exp 1L0))
    E

    ;; Yes, it's different now:

    [3]> (e)
    2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746639193200305992181741359662904357290033429526059563073813232862794349076323382988075319525101901157383418793070215408914993488416750924476146066808226480016847741185374234544243710753907774499206955170277L0
    [4]> (expt (e) (* pi (0L0 1L0)))
    (-1.0L0
    4.4159741848488758531726160656089533202761352843950741810509537213649392995282943592745789204277939266569808322194586729569872670819480502770846786874305201718215791310948505090575804581063383254057295785111584108995354602565727992662846155123312661407353868677580854724681334059286394407931654623717140025991L-309)
    [5]> (integer-decode-float (imagpart *))
    142711064542513797375761164792883845232670401481971869708584082397661513134960289997663095233931200321823663175395230178627245138199368488725376466632604576788052034909463540163675838543561814928154094082496959718469512486587999806404204178019545267375820679176559019490895257943507931319481850929509967670757 ;
    -2048 ;
    1

    ;; Hunky-dory: accurate to its precision.

    *Exercise for the reader:*
    how to fix the above naive definition of `e'?





      [?]Daniel Kochmański » 🌐
      @jackdaniel@functional.cafe

      @vnikolov (= 1/4 (0.25 0.0))

      (= (flo flo) (rat rat))

        [?]screwlisp » 🌐
        @screwlisp@gamerplus.org

        @jackdaniel
        tbh I am pretty sure I am confused every time about the relation between (some floats).
        @loke @dougmerritt @vnikolov

          [?]Vassil Nikolov | Васил Николов » 🌐
          @vnikolov@ieji.de

          «CL is mathematically precise»

          And here, too, is where intent also comes in.
          In contexts like the present one, the choice of a precise definition of ”mathematically precise” is also a matter of intent.

          For example, I can imagine an intent to replace automatically (17.17 0.0) with 17.17, which would match the behavior of `=’ and `equalp’.
          (With Common Lisp, one would have to do this manually, of course, which can be cumbersome.)
          And I don't think that ignoring letter case is “culturally consistent” with distinguishing between 1717/100 and 17.17, but again, your intended mileage may vary.
          Also, note that
          (and (realp x) (equalp x y))
          does not imply
          (realp y)
          (ditto for `=’).

          There are other more interesting cases in wider design space, like having a complex number with one component a floating-point number and the other a rational number.
          One very famous case for this is
          (/ (log -1) (sqrt -1))
          (besides computer algebra systems, this requires some special casing, but arguably, acceptably little).

          While `equalp’ can indeed be useful, sometimes very useful, using it successfully requires much more care than using `equal’.
          The distinction between `eq’ and `eql’ is rather different in this respect, because `eql’ insists (1) on the types being the same and (2) on immutability for two things that are not `eq’.
          Thus using `eql’ successfully is much more straightforward than `equalp'.
          Unlike the other three, the latter's definition is not really straightforward, more an idiosyncratic combination of trade-offs and historical reasons.
          And it is by far not the only workable extension of `equal’.

          @jackdaniel @screwlisp @dougmerritt

            [?]Vassil Nikolov | Васил Николов » 🌐
            @vnikolov@ieji.de

            By the way, while
            (equalp 17.17 (17.17 0.0))
            is indeed true,
            (equalp 1717/100 17.17)
            is false, even though
            (float 1717/100)
            prints as 17.17 and
            (rationalize 17.17)
            is 1717/100.

            At this time, my take on this is that everybody draws the line somewhere, but I'll think again 🙂.

            @screwlisp @dougmerritt

              [?]Vassil Nikolov | Васил Николов » 🌐
              @vnikolov@ieji.de

              Hmmm...

              I do wish I could answer with certainty without looking it up what the value of (equalp 123.456 (123.456 0.0)) is...
              I only _think_ it is true; not good enough.

              @dougmerritt @screwlisp

                adb boosted

                [?]adb » 🌐
                @adbenitez@mastodon.de

                0 ★ 7 ↺

                [?]OCTADE » 🌐
                @octade@soc.octade.net

                "Remember that there is a distinction between a programming language and a graphical user interface. Don't confuse snazzy graphics (generated using someone else's libraries and tools) with good programming."
                ~ Bjarne Stroustrup (C++ Inventor)

                @infostorm@a.gup.pe @hacking@a.gup.pe @c@a.gup.pe @programming@a.gup.pe @dev@a.gup.pe @quotes@a.gup.pe