Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
nikhilgarg
Specialist II
Specialist II

Prob regarding Floor ?

Hey,

If we use floor(2.6), it will give the lower value i.e.2.0

But, i dont understand following result:

floor( 3.88 , 0.1 ) returns 3.8

floor( 3.88 , 5 ) returns 0

floor( 1.1 , 1 , 0.5 ) returns 0.5

Can anyone help ?

tHanks

1 Solution

Accepted Solutions
Not applicable

floor(x [ , base [ , offset ]])

Rounding of x downwards to the nearest multiple of base with an offset of offset. The result is a number.

In your case x=3.88 base=0.1 offset is not mentioned

You should check for the largest multiple of 0.1(.....,3.5,3.6,3.7,3.8) which is less than 3.88, is 3.8

For suppose x=4.05 base=0.2 offset is not mentioned

The largest multiple of 0.2 (......,3.6,3.8,4.0) which is less than 4.05 is 4.0.

Similarly x=3.88, base=5,offset is not mentioned

largest multiple of 5 which is  less than 3.88 is 0

when x=1.1,base=1,offset=0.5

we will do that in two steps,when x=1.1, base=1 and then solve for offset. The solution for this is 1

When we add offset in floor() this it is just flooring the answer in above case by offset value therefore it becomes 0.5

View solution in original post

10 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

floor( 3.88 , 0.1 ) returns 3.8      --- This rounds upto 0.1 so 3.88 becomes 3.8 (0.08 is rounded)

floor( 3.88 , 5 ) returns 0            --- This rounds upto 5, so 3.88 becomes 0 (since 3.88 is less than 5)

floor( 6.88 , 5 ) returns 5  --- Here we are rounding by multiples of 5

floor(10.22, 5) returns 5 --- Same as above

floor( 1.1 , 1 , 0.5 ) returns 0.5 - floor( 1.1 , 1) rounds to 1 and offset 0.5 will return 0.5

floor( 2.1 , 1 , 0.5 ) returns 0.5 - floor( 2.1 , 1) rounds to 2 and offset 0.5 will return 1.5



Hope it helps you.

Regards,

Jagan.

nikhilgarg
Specialist II
Specialist II
Author

Hey thanx, but i am confused about that:

floor( 3.88 , 0.1 ) , does this 0.1 indicates it will round to 1 decimal place after decimal.

floor( 6.88 , 5 ) , i dont understand what 5 means here, is it nmber of place or what?


THanks

CELAMBARASAN
Partner - Champion
Partner - Champion

Range is 0 to 1

Floor(3.88) it will give you the result without any decimal points, which is equal to Floor(3.88, 1)

Range is 0 to 5

When it comes to Floor(3.88, 5) will give you 0, but Floor(6, 5) will give you 5
Assume 5 is the higher round off and 0 is lower one

Floor(3.88, 0.1) it will give you the result up to 1 decimal point

Not applicable

floor(x [ , base [ , offset ]])

Rounding of x downwards to the nearest multiple of base with an offset of offset. The result is a number.

In your case x=3.88 base=0.1 offset is not mentioned

You should check for the largest multiple of 0.1(.....,3.5,3.6,3.7,3.8) which is less than 3.88, is 3.8

For suppose x=4.05 base=0.2 offset is not mentioned

The largest multiple of 0.2 (......,3.6,3.8,4.0) which is less than 4.05 is 4.0.

Similarly x=3.88, base=5,offset is not mentioned

largest multiple of 5 which is  less than 3.88 is 0

when x=1.1,base=1,offset=0.5

we will do that in two steps,when x=1.1, base=1 and then solve for offset. The solution for this is 1

When we add offset in floor() this it is just flooring the answer in above case by offset value therefore it becomes 0.5

Anonymous
Not applicable

Hi Nikhil,

Check this post Rounding-errors by henric.

Regards

Neetha

nikhilgarg
Specialist II
Specialist II
Author

Hey thanx shiva. This helps me understanding the floor. But if u see

example given by jagan, floor(10.22,5) should give 10 but according to

jagan it give 5 . can u help in dis?

On 26-Feb-2015 4:05 PM, "Shiva Kumar Thoutam" <qcwebmaster@qlikview.com>

CELAMBARASAN
Partner - Champion
Partner - Champion

That would be a typo

nikhilgarg
Specialist II
Specialist II
Author

Ohk, so you mean: floor(10.22, 5) returns 10. Isn't it ??

And also does offset subtracts that much value from returned value ?

Anonymous
Not applicable

yes nikhil its typo

floor(10.22, 5) returns 10  --- it 's rounding by multiples of 5