HISE Logo Forum
    • Categories
    • Register
    • Login

    Math Cubic Root function?

    Scheduled Pinned Locked Moved General Questions
    6 Posts 4 Posters 233 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • JulesVJ
      JulesV
      last edited by

      As the title says, I couldn't find a cubic root function equivalent to std::cbrt

      Any ideas?

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @JulesV
        last edited by

        @JulesV Math.pow(x, 1/3);?

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        JulesVJ 1 Reply Last reply Reply Quote 2
        • JulesVJ
          JulesV @d.healey
          last edited by

          @d-healey Yes, that's it, thanks. I had to use If/else Statement for negative values, though.

          Christoph HartC d.healeyD 2 Replies Last reply Reply Quote 0
          • Christoph HartC
            Christoph Hart @JulesV
            last edited by

            @JulesV abs is your friend here.

            1 Reply Last reply Reply Quote 1
            • d.healeyD
              d.healey @JulesV
              last edited by d.healey

              @JulesV What about something like this

              inline function cubeRoot(x)
              {
                  return x < 0 ? -Math.pow(-x, 1/3) : Math.pow(x, 1/3);
              }
              

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              ustkU 1 Reply Last reply Reply Quote 1
              • ustkU
                ustk @d.healey
                last edited by

                @d-healey or this

                return Math.sign(x) * Math.pow(Math.abs(x), 1/3);
                

                But a benchmark shows no difference in efficiency

                Hise made me an F5 dude, browser just suffers...

                1 Reply Last reply Reply Quote 2
                • First post
                  Last post

                27

                Online

                1.9k

                Users

                12.4k

                Topics

                108.0k

                Posts