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
    Julia Evans (b0rk@mastodon.social)'s status on Wednesday, 11-Jan-2023 22:46:49 JST Julia Evans Julia Evans

    today I'm thinking about how floating point numbers can be treacherous -- what are specific examples of when they've betrayed you?

    so far I have:

    * money calculations where you need to get the exact correct answer
    * twitter's tweet IDs are bigger than 2^53 and can't be represented as a Javascript number, you have to use a string
    * implementing numerical algorithms (like matrix multiplication) (I've never done this)

    In conversation Wednesday, 11-Jan-2023 22:46:49 JST from mastodon.social permalink
    • Embed this notice
      pettter (pettter@mastodon.acc.umu.se)'s status on Wednesday, 11-Jan-2023 22:46:48 JST pettter pettter
      in reply to

      @b0rk Overall needing to do comparisons within some epsilon rather than exact, whether that's in money calculations or otherwise. I.e. 0 + 0.1 + 0.2 != 0.3

      In conversation Wednesday, 11-Jan-2023 22:46:48 JST permalink
    • Embed this notice
      pettter (pettter@mastodon.acc.umu.se)'s status on Wednesday, 11-Jan-2023 22:49:19 JST pettter pettter
      in reply to

      @b0rk It could be a bunch of things, like if you're making a game and have various bonuses and drawbacks, and want to check if you're back to zero for some reason, and then instead of checking "am I within epsilon of 0" you check "am I exactly zero", because "all" you're doing is +- some percentage so intuitively it _should_ work.

      In conversation Wednesday, 11-Jan-2023 22:49:19 JST permalink
    • Embed this notice
      Julia Evans (b0rk@mastodon.social)'s status on Wednesday, 11-Jan-2023 22:49:20 JST Julia Evans Julia Evans
      in reply to
      • pettter

      @pettter do you have any other examples than money calculations? I'm struggling to come up with specific examples

      In conversation Wednesday, 11-Jan-2023 22:49:20 JST permalink
    • Embed this notice
      pettter (pettter@mastodon.acc.umu.se)'s status on Wednesday, 11-Jan-2023 22:50:30 JST pettter pettter
      in reply to

      @b0rk Physics calculations in games can have similar problems, e.g. in checking collisions or if you're at ground level or w/e. (this is why you use a game engine)

      In conversation Wednesday, 11-Jan-2023 22:50:30 JST permalink

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.