🤖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

    Scheduled Pinned Locked Moved UIFlow
    5 Posts 3 Posters 4.9k 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.
    • C Offline
      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 Offline
        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 Offline
          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
          • RIDDSprojectsR Offline
            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.

            ATOM LITE | ATOM MATRIX | CORE | CORE2 | STAMP-PICO | CORE.INK | PAPER V1.1
            RESEARCH | INNOVATION | DEVELOPMENT | DESIGN | SUSTAINABILITY
            and electronics

            Nederland

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

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

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post