difference between floor() and rounddown() function

Certified Senior Developer

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

  Discussion posts and replies are publicly visible

Parents
  • Hi paragk,

    Floor() function relies on 2 parameters called (Number, Significance).Here significance rounds the highest multiple of the significance(decimal) which is less than a number.For example:
    floor(2.8888, .01) returns 2.88 and the result set is same for the significance values .01,.02,.03,.04 i.e,floor(2.8888, .04) returns 2.88 while it varies for floor(2.8888,.05) as 2.85 that means the value is getting rounded to the nearest multiple of the significance.

    rounddown() also expects 2 parameters called (Number,num_digits) Number is of decimal type which rounds the number to specific digit.
    Example; round(1.8888, 0) returns 2,
    round(1.8888, 1) returns 1.9.If there is a case to round down a number to the nearest hundred in such case set the second parameter of rounddown() to -2.

    Another case is like , when you need a desired result use fixed() function with rounddown() i.e, fixed( 5.6567) returns 5.66.

    ceiling(number,significance) returns the lowest multiple value of the significance which is greater than the number.
    Example:ceiling(1.5) returns 2
    ceiling(1.5,.05) returns 1.5

    roundup(number, num_digits ) rounds the number up to nearest hundred .
    Example: round(1.8888, 1) returns 1.9
    round(1.8888, 2) returns 1.89

    As rounddown() function use fixed() to get the desired result.


    Thanks,
    ravalik
Reply
  • Hi paragk,

    Floor() function relies on 2 parameters called (Number, Significance).Here significance rounds the highest multiple of the significance(decimal) which is less than a number.For example:
    floor(2.8888, .01) returns 2.88 and the result set is same for the significance values .01,.02,.03,.04 i.e,floor(2.8888, .04) returns 2.88 while it varies for floor(2.8888,.05) as 2.85 that means the value is getting rounded to the nearest multiple of the significance.

    rounddown() also expects 2 parameters called (Number,num_digits) Number is of decimal type which rounds the number to specific digit.
    Example; round(1.8888, 0) returns 2,
    round(1.8888, 1) returns 1.9.If there is a case to round down a number to the nearest hundred in such case set the second parameter of rounddown() to -2.

    Another case is like , when you need a desired result use fixed() function with rounddown() i.e, fixed( 5.6567) returns 5.66.

    ceiling(number,significance) returns the lowest multiple value of the significance which is greater than the number.
    Example:ceiling(1.5) returns 2
    ceiling(1.5,.05) returns 1.5

    roundup(number, num_digits ) rounds the number up to nearest hundred .
    Example: round(1.8888, 1) returns 1.9
    round(1.8888, 2) returns 1.89

    As rounddown() function use fixed() to get the desired result.


    Thanks,
    ravalik
Children
No Data