Round up

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ruslan

    #1

    Round up

    How can I round up a float number?



    For example:

    If I have a number 3.6 I want to obtain 4 and

    If I have a number 3.1 also to obtain 4



    Thanks a lot.



    Ruslan


  • Frank Mulvenny

    #2
    Re: Round up

    Ruslan wrote:[color=blue]
    > How can I round up a float number?[/color]

    Math.Ceiling


    Comment

    • Uri Dor

      #3
      Re: Round up

      add 0.5 and truncate?

      Ruslan wrote:[color=blue]
      > How can I round up a float number?
      >
      >
      >
      > For example:
      >
      > If I have a number 3.6 I want to obtain 4 and
      >
      > If I have a number 3.1 also to obtain 4
      >
      >
      >
      > Thanks a lot.
      >
      >
      >
      > Ruslan
      >
      >[/color]

      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: Round up

        Ruslan,
        Have you tried System.Math.Cei ling? Which returns the smallest whole number
        greater than or equal to the specified number.

        Note for negative numbers it will return numbers closer to zero.

        Ceiling(-3.6) will return -3.

        The function System.Match.Fl oor will return the smallest whole number less
        than or equal to the specified number.

        Hope this helps
        Jay

        "Ruslan" <ruslan_albu@ho tmail.com> wrote in message
        news:%236eF3GbW DHA.2384@TK2MSF TNGP10.phx.gbl. ..[color=blue]
        > How can I round up a float number?
        >
        >
        >
        > For example:
        >
        > If I have a number 3.6 I want to obtain 4 and
        >
        > If I have a number 3.1 also to obtain 4
        >
        >
        >
        > Thanks a lot.
        >
        >
        >
        > Ruslan
        >
        >[/color]


        Comment

        • Ruslan

          #5
          Re: Round up

          Thanks, Jay



          It helped me.



          Ruslan



          "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow@ema il.msn.com> wrote in message
          news:#QccDRcWDH A.1872@TK2MSFTN GP12.phx.gbl...[color=blue]
          > Ruslan,
          > Have you tried System.Math.Cei ling? Which returns the smallest whole[/color]
          number[color=blue]
          > greater than or equal to the specified number.
          >
          > Note for negative numbers it will return numbers closer to zero.
          >
          > Ceiling(-3.6) will return -3.
          >
          > The function System.Match.Fl oor will return the smallest whole number less
          > than or equal to the specified number.
          >
          > Hope this helps
          > Jay
          >
          > "Ruslan" <ruslan_albu@ho tmail.com> wrote in message
          > news:%236eF3GbW DHA.2384@TK2MSF TNGP10.phx.gbl. ..[color=green]
          > > How can I round up a float number?
          > >
          > >
          > >
          > > For example:
          > >
          > > If I have a number 3.6 I want to obtain 4 and
          > >
          > > If I have a number 3.1 also to obtain 4
          > >
          > >
          > >
          > > Thanks a lot.
          > >
          > >
          > >
          > > Ruslan
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...