difference between floor() and rounddown() function

Certified Lead Developer

what is the difference between floor() and rounddown() function or ceiling() and roundup() function ?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Hi,

    floor() rounds the number down to the nearest multiple of the specified significance. i.e. The number will be rounded to the highest multiple of the significance that is less than the number.
    for eg.
    floor(2.8888,2) will give you 2 because the highest multiple of the significance (2) which is less than 2.8888 is 2 X 1= 2.
    In the same example if you make the significance as 3 , the result will be 0 because the highest multiple of 3 which is less than 2.8888 is
    3 X 0=0.
    rounddown() function rounds the number down to the specified digit and has nothing to do with significance as in case of floor().
    for eg.
    round(2.8888, 2) will give you 2.89
    round(2.8888, 3) will give you 2.889
    in this example , 2 and 3 represents the digit or place to which the number will be rounded down to the nearest 10^(-num_digits) and not the significance as in case of floor().

    The ceiling() function rounds the number up to the nearest multiple of the specified significance but in case of ceiling, the number will be rounded to the lowest multiple of the significance that is greater than the number.
    for eg. ceiling(2.8888,2) will give you 4 as 4 is the lowest multiple of 2 (the significance) which is greater than 2.8888.
    and ceiling(2.8888,3) will give you 3 as 3 is the is the lowest multiple of 3 (the significance) which is greater than 2.8888.

    roundup() function rounds the number up to the specified digit and has nothing to do with significance as in case of ceiling().
    round(2.8888, 2) will give you 2.89
    round(2.8888, 3) will give you 2.889
    in this example , 2 and 3 represents the digit or place to which the number will be rounded up to the nearest 10^(-num_digits) and not the significance as in case of floor().
Reply
  • 0
    Certified Lead Developer
    Hi,

    floor() rounds the number down to the nearest multiple of the specified significance. i.e. The number will be rounded to the highest multiple of the significance that is less than the number.
    for eg.
    floor(2.8888,2) will give you 2 because the highest multiple of the significance (2) which is less than 2.8888 is 2 X 1= 2.
    In the same example if you make the significance as 3 , the result will be 0 because the highest multiple of 3 which is less than 2.8888 is
    3 X 0=0.
    rounddown() function rounds the number down to the specified digit and has nothing to do with significance as in case of floor().
    for eg.
    round(2.8888, 2) will give you 2.89
    round(2.8888, 3) will give you 2.889
    in this example , 2 and 3 represents the digit or place to which the number will be rounded down to the nearest 10^(-num_digits) and not the significance as in case of floor().

    The ceiling() function rounds the number up to the nearest multiple of the specified significance but in case of ceiling, the number will be rounded to the lowest multiple of the significance that is greater than the number.
    for eg. ceiling(2.8888,2) will give you 4 as 4 is the lowest multiple of 2 (the significance) which is greater than 2.8888.
    and ceiling(2.8888,3) will give you 3 as 3 is the is the lowest multiple of 3 (the significance) which is greater than 2.8888.

    roundup() function rounds the number up to the specified digit and has nothing to do with significance as in case of ceiling().
    round(2.8888, 2) will give you 2.89
    round(2.8888, 3) will give you 2.889
    in this example , 2 and 3 represents the digit or place to which the number will be rounded up to the nearest 10^(-num_digits) and not the significance as in case of floor().
Children
No Data