Math round()

Home Forums General Programming Math round()

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #11425
    zeoka
    Participant
      • Topics: 73
      • Replies: 466
      • Total: 539
      • ★★★

      myvalue = (“getByte” / 8) + “?”
      “?” = “getByte” – ((“getByte” / 8)*8)
      I believed LUA rounds automatically but this not works

      a way to have (“getByte” / 8) rounded then i can substract from “getByte”

      or other way ? i need that “?” = 0 to 7

      • This topic was modified 10 years, 9 months ago by zeoka.
      #11427
      atom
      Keymaster
        • Topics: 159
        • Replies: 2945
        • Total: 3104
        • ★★★★★
        #11429
        zeoka
        Participant
          • Topics: 73
          • Replies: 466
          • Total: 539
          • ★★★

          modulo !

          i used it to detect a pair/unpair byte

          #12524
          msepsis
          Participant
            • Topics: 219
            • Replies: 732
            • Total: 951
            • ★★★

            I go to the link atom provided and see:

            math.modf

            Return the integral and fractional parts of the given number.
            > = math.modf(5)
            5 0
            > = math.modf(5.3)
            5 0.3
            > = math.modf(-5.3)
            -5 -0.3
            If you want the modulus (remainder), look for the modulo % operator instead.[3]

            Ok. I want the remainder… where do i go to “look for the modulo % operator instead”?? I don’t understand what that’s trying to tell me.
            I’ll google it but it would be helpful to get a less cryptic answer. I don’t get what this is saying…

            edit: ok..i *think* i get it… per your example in the “mask to 7 bits” thread that lead me here, zeoka value%127 will mask “value” to 7 bits.

            edit2: yep that did the trick – far more simple of a solution than I was expecting.

            • This reply was modified 10 years, 8 months ago by msepsis.
            • This reply was modified 10 years, 8 months ago by msepsis.

            Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen

          Viewing 4 posts - 1 through 4 (of 4 total)
          • The forum ‘Programming’ is closed to new topics and replies.
          There is currently 0 users and 60 guests online
          No users are currently active
          Forum Statistics
          Threads: 2,495, Posts: 17,374, Members: 77,605
          Most users ever online was 12 on January 22, 2019 3:47 pm
          Ctrlr