GNU social JP
  • FAQ
  • Login
GNU social JPは日本のGNU socialサーバーです。
Usage/ToS/admin/test/Pleroma FE
  • Public

    • Public
    • Network
    • Groups
    • Featured
    • Popular
    • People

Conversation

Notices

  1. Embed this notice
    abadidea (0xabad1dea@infosec.exchange)'s status on Friday, 02-Feb-2024 16:27:46 JST abadidea abadidea

    A few times I have told the anecdote that the singly most baffling thing I ever saw in a code review — not the most insecure, just the most “how could a real programmer have written this? how could this ever make sense?” thing — was simply a C++ variable “number_of_trucks” … declared as float. Unambiguously referring to real physical trucks in a fleet.

    Reader, it’s been over ten years and I am blowing the gods damn whistle. I had edited that story to protect the guilty: the variable was named number_of_planes. It was shipped by a company whose name begins with “B” and rhymes with “GOING out of business.”

    In conversation Friday, 02-Feb-2024 16:27:46 JST from infosec.exchange permalink
    • Haelwenn /элвэн/ :triskell: and Polychrome :blabcat: like this.
    • Haelwenn /элвэн/ :triskell: repeated this.
    • Embed this notice
      squaregoldfish (squaregoldfish@mastodon.social)'s status on Friday, 02-Feb-2024 18:18:20 JST squaregoldfish squaregoldfish
      in reply to

      @0xabad1dea I mean, float kinda sounds like fleet

      In conversation Friday, 02-Feb-2024 18:18:20 JST permalink
    • Embed this notice
      Brendan Jones (brendanjones@fosstodon.org)'s status on Friday, 02-Feb-2024 18:18:20 JST Brendan Jones Brendan Jones
      in reply to
      • squaregoldfish

      @squaregoldfish @0xabad1dea planes float, right? Sounds logical!

      In conversation Friday, 02-Feb-2024 18:18:20 JST permalink
    • Embed this notice
      Ryan Castellucci (they/them) :nonbinary_flag: (ryanc@infosec.exchange)'s status on Friday, 02-Feb-2024 21:00:17 JST Ryan Castellucci (they/them) :nonbinary_flag: Ryan Castellucci (they/them) :nonbinary_flag:
      in reply to

      @0xabad1dea I think I might forgive counting boats using a float purely because it's funny, but holy shit yikes.

      In conversation Friday, 02-Feb-2024 21:00:17 JST permalink
    • Embed this notice
      mad (ae35@hal9.ooo)'s status on Saturday, 03-Feb-2024 09:56:28 JST mad mad
      in reply to

      @0xabad1dea I've seen float with auto increment being used as the primary key in a database.

      In conversation Saturday, 03-Feb-2024 09:56:28 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      abadidea (0xabad1dea@infosec.exchange)'s status on Saturday, 03-Feb-2024 09:58:08 JST abadidea abadidea
      in reply to

      Also if you don’t know what a float is (because you’re not a programmer or have only worked with very high level languages that try to conceal these details) then my horror makes no sense so I will break it down for you

      If you declare a number value to be a float, that is telling the computer two things:

      • first, that the value is allowed to be fractional and not just whole numbers (integers). This means that if someone reports that the fleet gained 2.3 planes or lost 0.01 planes, the computer would be like yeah, sure, that makes sense, let me write that down.

      • second, doing math with fractions is much more computationally complicated than whole numbers. Telling the computer a value is a “float” is explicitly telling it that you want it to use the fastest methods it has available to do the math, even if they’re not 100% accurate down to the smallest fraction of a fraction. You are saying it’s okay to lose track of a hundredth of a plane here or there as long as you count the planes really fast.

      The intended use of floats is things like video game graphics: you can’t tell if the height of the enemy is 6.200002 meters or 6.2 meters exactly, and letting the computer not worry about the difference makes the calculations much faster. You should never, ever use floats for things like money, because over the course of many successive adds and subtracts, entire cents or dimes will just pop in and out of existence. Or, like, some unspecified fraction of a plane, which is probably not what you want.

      In conversation Saturday, 03-Feb-2024 09:58:08 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      Sylvhem (sylvhem@eldritch.cafe)'s status on Saturday, 03-Feb-2024 09:59:05 JST Sylvhem Sylvhem
      in reply to

      @0xabad1dea Experience recently thaugh us that fractional Boeing planes are a thing.

      In conversation Saturday, 03-Feb-2024 09:59:05 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      abadidea (0xabad1dea@infosec.exchange)'s status on Saturday, 03-Feb-2024 10:00:51 JST abadidea abadidea
      in reply to
      • C222

      @C222 aaaaaaAAAAAAAAAAAAA

      In conversation Saturday, 03-Feb-2024 10:00:51 JST permalink
    • Embed this notice
      C222 (c222@mas.to)'s status on Saturday, 03-Feb-2024 10:00:51 JST C222 C222
      in reply to

      @0xabad1dea OOH. Also. The byte order for the floats wasn't little or big endian. It was something like C,D,A,B because the 16-bit words were big-endian, but the bytes were little.

      I asked their "developer" why I was getting garbage and they replied with the wiki page for IEEE754.

      In conversation Saturday, 03-Feb-2024 10:00:51 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      C222 (c222@mas.to)'s status on Saturday, 03-Feb-2024 10:00:52 JST C222 C222
      in reply to

      @0xabad1dea When I was a new developer one of my responsibilities was interfacing with industrial equipment via SCADA protocols. One fledgling manufacturer decided that _everything_ needed to be 32-bit floats.

      watthours_imported? float, that's fine.
      batteries_installed? float
      is_activated? float! (0.0 was off)
      serial_number? was a list of 10-some floats (e.g. 65.0 was ascii "A")

      They're out of business now.

      In conversation Saturday, 03-Feb-2024 10:00:52 JST permalink
    • Embed this notice
      C222 (c222@mas.to)'s status on Saturday, 03-Feb-2024 10:01:45 JST C222 C222
      in reply to
      • Pointing Device

      @pointingdevice @0xabad1dea It could have been that for all I remember. But that also deserves to stay in the 1970s.

      In conversation Saturday, 03-Feb-2024 10:01:45 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      Pointing Device (pointingdevice@social.restless.systems)'s status on Saturday, 03-Feb-2024 10:01:47 JST Pointing Device Pointing Device
      in reply to
      • C222

      @C222 @0xabad1dea That's exciting, because that would be yet another variation on the classic PDP-11 middle-endian format (B,A,D,C – two little endian 16-bit words, but with the high word first).

      In conversation Saturday, 03-Feb-2024 10:01:47 JST permalink
    • Embed this notice
      Bradley Schaefer (soulcutter@ruby.social)'s status on Saturday, 03-Feb-2024 10:02:31 JST Bradley Schaefer Bradley Schaefer
      in reply to

      @0xabad1dea

      The general public: Surely critical corporate software is written to the highest standards and will not ever fail.

      Veteran Developers: I’ve seen things that make me wonder how anything works at all - especially in critical systems.

      yes, there are exceptions, this is hyperbole

      In conversation Saturday, 03-Feb-2024 10:02:31 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      vriesk (Jan Srz) (vriesk@hachyderm.io)'s status on Saturday, 03-Feb-2024 10:25:11 JST vriesk (Jan Srz) vriesk (Jan Srz)
      in reply to

      @0xabad1dea but, have you seen timestamps (expressed as seconds since the Epoch) declared as a 32-bit float?

      Because I did. In production code. In a BIG company.

      The result was a ~2-minute precision of said timestamps, which triggered interesting bugs elsewhere.

      In conversation Saturday, 03-Feb-2024 10:25:11 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      abadidea (0xabad1dea@infosec.exchange)'s status on Saturday, 03-Feb-2024 10:26:54 JST abadidea abadidea
      in reply to
      • vriesk (Jan Srz)

      @vriesk ada lovelace christ

      In conversation Saturday, 03-Feb-2024 10:26:54 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      Tom Ritchford (tomswirly@toot.community)'s status on Saturday, 03-Feb-2024 10:27:54 JST Tom Ritchford Tom Ritchford
      in reply to

      @0xabad1dea The project was specc'ed to use integer arithmetic, so I spent a week writing a nice 64-bit fixed point arithmetic system.

      But this nice young man refused to cooperate. One of the things I'd been brought in to do was write unit tests, something he was completely against, so he'd made all these changes and never run the tests.

      I got fired. But they were too stupid to remove my privileges for the repo, so I watched his "work".

      3/

      In conversation Saturday, 03-Feb-2024 10:27:54 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.
    • Embed this notice
      Tom Ritchford (tomswirly@toot.community)'s status on Saturday, 03-Feb-2024 10:27:56 JST Tom Ritchford Tom Ritchford
      in reply to

      @0xabad1dea I worked for Ripple, not nice people at all. I got put on a project with a young man with very strong beliefs about his ability to write computer programs who had "written" a trading backend in "C++" - really C.

      (One of his beliefs, for example, was that making all variables static and global made the program run faster. Indeed, he had a lot of weird beliefs about what made programs faster, but since he refused to do any form of benchmark, I was skeptical.)

      2/

      In conversation Saturday, 03-Feb-2024 10:27:56 JST permalink
    • Embed this notice
      Tom Ritchford (tomswirly@toot.community)'s status on Saturday, 03-Feb-2024 10:27:57 JST Tom Ritchford Tom Ritchford
      in reply to

      @0xabad1dea A quibble: floating point numbers give exact values for addition, multiplication and subtraction involving integers if the results aren't too large.

      In 32-bit floating point, you can exactly represent all integers up to 16,777,217.

      > You should never, ever use floats for things like money

      You can't do things like compound interest and mortgage payments with integer arithmetic! 😁

      ---

      I have a relevant story here that you might find amusing.

      1/

      In conversation Saturday, 03-Feb-2024 10:27:57 JST permalink

      Attachments


    • Embed this notice
      Tom Ritchford (tomswirly@toot.community)'s status on Saturday, 03-Feb-2024 10:28:54 JST Tom Ritchford Tom Ritchford
      in reply to

      @0xabad1dea
      First he ripped out my 64-bit fixed point arithmetic, and replaced it with `int128_t` - which works by using two hardware 64-bit ints!

      My quick benchmarks showed me that this slowed all arithmetic down by a factor of about five.

      But then, even worse, since he had no understanding of how computer arithmetic worked, all his intermediate calculations were in 64-bit floating point, which then got converted back into `int128_t`.

      Of course, the product never came out.

      /thread

      In conversation Saturday, 03-Feb-2024 10:28:54 JST permalink
      Haelwenn /элвэн/ :triskell: likes this.

Feeds

  • Activity Streams
  • RSS 2.0
  • Atom
  • Help
  • About
  • FAQ
  • TOS
  • Privacy
  • Source
  • Version
  • Contact

GNU social JP is a social network, courtesy of GNU social JP管理人. It runs on GNU social, version 2.0.2-dev, available under the GNU Affero General Public License.

Creative Commons Attribution 3.0 All GNU social JP content and data are available under the Creative Commons Attribution 3.0 license.