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

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

Swift code: infix operator %%: MultiplicationPrecedence func %% <T: BinaryInteger> (num: T, modulus: T) -> T { (num % modulus + modulus) % modulus } print(-5 %% 3)

Download link

https://media.hachyderm.io/media_attachments/files/113/291/608/153/164/150/original/f9f6d0a7774973bc.png

Notices where this attachment appears

  1. Embed this notice
    Paul Cantrell (inthehands@hachyderm.io)'s status on Saturday, 12-Oct-2024 09:25:56 JST Paul Cantrell Paul Cantrell

    Does Swift not have a built-in / stdlib modulus operator, such that e.g. -5 mod 3 gives 1 (instead of -2, as -5 % 3 does)?

    It’s easy enough to add it, but…given the language’s careful attention to “remainder” versus “modulus” in its named functions and its docs, it really seems like something that should be in the lang!

    In conversation about 9 months ago from hachyderm.io permalink
  • 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.