HISE Logo Forum
    • Categories
    • Register
    • Login

    label.set value...

    Scheduled Pinned Locked Moved General Questions
    4 Posts 3 Posters 301 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.
    • 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 ;)

      ustkU 1 Reply Last reply Reply Quote 0
      • d.healeyD
        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
        • ustkU
          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
          

          Can't help pressing F5 in the forum...

          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

            37

            Online

            1.7k

            Users

            11.7k

            Topics

            102.0k

            Posts