fxDreema

    • Register
    • Login
    • Search
    • Back to the main page
    • Categories
    • Recent
    • Tags
    • Popular
    • Search

    Round up number

    Questions & Answers
    0
    3
    507
    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.
    • P
      Pheaktra Capo last edited by

      Hello everybody.
      I want to round up some number. For example:
      1.2389 to 1.24 (2 decimal)
      1.2389 to 1.239 (3 decimal)

      I use DoubleToString(variable,2) and it just cut out the number, not round up the number.
      Please help. Thanks in advance and have a nice day . . . .

      roar 1 Reply Last reply Reply Quote 0
      • roar
        roar @Pheaktra Capo last edited by roar

        @pheaktra-capo

        https://www.mql5.com/en/docs/math/mathfloor

        MathFloor() rounds the number to the nearest integer below. We can use it together with some basic maths:

        (MathFloor(1.2389*100)+1)/100 = 1.24

        (MathFloor(1.2389*1000)+1)/1000 = 1.239

        edit: oh, its probably bit easier with https://www.mql5.com/en/docs/math/mathceil

        Need small help? Tag me in your post
        Need big help? https://www.fiverr.com/big_algo/automate-your-winning-strategy-in-mql4-or-mql5

        P 1 Reply Last reply Reply Quote 0
        • P
          Pheaktra Capo @roar last edited by

          This is very useful to me. Thank you very much

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

          Online Users

          T
          M
          E
          D
          E
          K
          T
          E
          K
          A

          19
          Online

          146.8k
          Users

          22.4k
          Topics

          122.6k
          Posts

          Powered by NodeBB Forums | Contributors