Skip to main content
faraza4154
May 22, 2023
Question

Get value in integer without round off

  • May 22, 2023
  • 8 replies
  • 1 view

Hi I have value 2.67 I want to get this value in integer without round off i.e 2 (integer)

8 replies

mikes0011
Brainy
May 22, 2023

Then you want a decimal, not an integer.

The Expression Guru
stewart.burchell
May 22, 2023

Not entirely sure what you're wanting here. If you want any decimal to always be a rounded down integer (e.g. 2.67->2, 3.14->3, 99.99->99) then you can use fn!rounddown() on the decimal value and then cast to an integer.

mikes0011
Brainy
May 22, 2023

Among other things, no less.  round(), trunc(), floor(), cieling() (though not in this case), etc, can all deal with "convert decimal to integer" problems.  However in this case it sounded (to me at least) like they want "2.67" and don't understand why it's turning to just "2" after being shoehorned into an INTEGER value..

The Expression Guru
stewart.burchell
May 22, 2023

Ok I can see how that might be an interpretation...if so then that's a pretty basic misapprehension as to how data typing works...I'd recommend a strong dose of 'Data Types 101'...

May 22, 2023

Try using int function, I have tried it and it's giving me integer without rounding it off. I believe this will suite your requirement perfectly.

int(2.67)