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
    EvilTofu (eviltofu@kopiti.am)'s status on Wednesday, 16-Apr-2025 13:01:53 JST EvilTofu EvilTofu

    How do I solve the problem of Swift encoding and decoding Date variables with a little loss of precision when using a JSONEncoder/JSONDecoder? After running the Date through with .iso8601 encoding, I find the Date variables are off by under 1 second.

    In conversation about a month ago from kopiti.am permalink
    • Embed this notice
      Dash 🇸🇬 (dashrandom@kopiti.am)'s status on Wednesday, 16-Apr-2025 13:01:53 JST Dash 🇸🇬 Dash 🇸🇬
      in reply to

      @eviltofu short answer, you can't.

      Long answer, swift encodes date as a number of seconds. This value is stored as a double. Doubles and floats and anything with decimand places are never 100% accurate.

      See: https://stackoverflow.com/questions/4776813/inconsistencies-with-double-data-type-in-c

      And: https://youtu.be/O6FsyQZzJJ0

      In conversation about a month ago permalink

      Attachments


      1. Mr. Incredible learns the truth about floating point numbers
        from Meme Dev
        Why 0.1 + 0.2 ≠ 0.3 and what the hell is IEEE 754? Let's find out.If you enjoyed the video, please leave a like and a comment.Subscribe for more chill progra...

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.