• yucandu@lemmy.world
    link
    fedilink
    English
    arrow-up
    7
    ·
    4 hours ago

    I had to just emulate floating points to save pulling in the giant print float library in stm32 to save flash memory. And then I learned that’s what all the pros do IRL anyway.

    • VinegarChunks@lemmus.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      14 minutes ago

      I am hard pressed to find anyone irl who would be impressed by this but I made a spreadsheet that converts hexadecimal into float using only standard excel formulas.

  • Quetzalcutlass@lemmy.world
    link
    fedilink
    English
    arrow-up
    27
    ·
    edit-2
    5 hours ago

    I feel obligated to post a link to this excellent (albeit incomplete) writeup of posits and unums, which can more accurately represent common fractions in memory at the same (or lower) bit size compared to traditional floating point.

    Said page also includes the single best slightly-above-entry-level explanation of how floating point works I’ve ever seen.

    • LurkingLuddite@piefed.social
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 hours ago

      Isn’t a big point of floating point that it can easily have mathematical operators done on them on CPUs? Sure, complex circuitry is no big deal these days, but IIRC, there were very good reasons for what was chosen.

      • Quetzalcutlass@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        2 hours ago

        One of the linked papers makes the claim that the circuitry would be less complex than that needed for floats, but also includes this note:

        Floats have one advantage over posits for the hardware designer: the fixed location of bits for the exponent and the fraction mean they can be decoded in parallel. With posits, there is a little serialization in having to determine the regime bits before the other bits can be decoded. There is a simple workaround for this in a processor design, similar to a trick used to speed the exception handling of floats: Some extra register bits can be attached to each value to save the need for extracting size information when decoding instructions.

        The proposed system also lacks NaN and separate positive/negative infinities, so it wouldn’t be a drop-in replacement.

    • terranoid@lemmy.cafe
      link
      fedilink
      English
      arrow-up
      9
      ·
      edit-2
      5 hours ago

      i have so many protocols to represent the most common fractions perfectly without needing more than just ONE bit. They even work with positive and negative infinity!

      The trick is to first negotiate the protocol youre using.

      protocol schema 1/2

      1 bit, little endian

      if one: value is exactly 1/2

      If zero: value is NOT one half

      Schema 1/3

      if one: value is 1/3

    • Quetzalcutlass@lemmy.world
      link
      fedilink
      English
      arrow-up
      3
      ·
      5 hours ago

      Ah, Apache Commons: for those who felt Java’s standard library wasn’t bloated enough already.

      (I kid, I kid, though it was always funny just how many basic features seemed to be missing from Java back in the day despite its massive bundled library, leading to seemingly every major project adding Commons as a dependency. Not as much as thing these days AFAIK)