Forum

    • Register
    • Login
    • Search
    • Categories

    label.set value...

    General Questions
    3
    4
    76
    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.
    • Y
      yall last edited by

      hello, I am using a Label to display the values ​​of my buttons.
      I am using Label.set ("text", value);

      but the problem is that on percentage, the label displays 0, 0.1567382783 ...
      I do not remember and I cannot find how to modify this. I would like it to display 10 11 67%
      . as I have about 30 buttons, each has its value in linear, in freq, in% ....
      an idea?
      thank you 😉

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

        Math.round() or Engine.doubleToString()

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

        1 Reply Last reply Reply Quote 3
        • ustk
          ustk @yall last edited by ustk

          @yall A percentage is nothing but a ratio value x 100... But if you just multiply by 100, then you'll get all the decimals you certainly don't want.
          So if you want a rounded value:

          Math.round(value * 100);
          

          and if you still want decimals

          Engine.doubleToString(value * 100, 1); // where 1 is the number of decimals
          

          I cannot help pressing F5 in the forum...
          Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

          1 Reply Last reply Reply Quote 2
          • Y
            yall last edited by

            @d-healey @ustk thank u 😉

            label1.set("text", Math.round(value * 100));

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

            9
            Online

            983
            Users

            6.6k
            Topics

            60.8k
            Posts