🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    round to one decimal in UI flow

    UIFlow
    3
    5
    3.0k
    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.
    • C
      csierra67
      last edited by

      Hi there,

      Is there a way to round a variable to 1 decimal like in Python round(3.14,1) achieves 3.1
      In the Math folder of UI flow, there is a round operator but there are only 3 possibilities : round, roundup and round down.
      I am using the environement sensor and my temperature shows up with plenty of non signidicant decimals 28.1234 deg C. I would like to indicate 28.1..
      Did I miss something ?

      M 1 Reply Last reply Reply Quote 0
      • M
        mtylerjr @csierra67
        last edited by

        @csierra67 could you multiply by 10, then round, then divide by 10?

        1 Reply Last reply Reply Quote 0
        • C
          csierra67
          last edited by

          Thanks a lot ! Did not come to me as it is implemented directly in u pythonj but I remember having read about this workaround when I used to program in other languages.
          Took me a little bit of time to set this up in UI Flow but it works perfectly of course.

          1 Reply Last reply Reply Quote 1
          • R
            RIDDSprojects
            last edited by

            Under Text you will find this option, at the very bottom: Reduce ... to x decimal places. It has been tucked away a bit, but works very well.

            CORE | CORE2 | CORE.INK | ATOM LITE | ATOM MATRIX | STAMP C3
            RESEARCH | INNOVATION | DEVELOPMENT | DESIGN | SUSTAINABILITY
            and electronics

            C 1 Reply Last reply Reply Quote 0
            • C
              csierra67 @RIDDSprojects
              last edited by

              @riddsprojects Thanks. Glad to have learned something, works well indeed

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