Hi I have value 2.67 I want to get this value in integer without round off i.e 2 (integer)
Discussion posts and replies are publicly visible
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.
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..
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'...
Not sure if this is the best way aroundtointeger( split(tostring(2.67, ".")[1] )
That's in effect the same outcome as fn!rounddown() so no advantage
Stewart Burchell said:fn!rounddown()
oddly, rounddown() requires a "number of places" parameter similar to trunc() (which i didn't realize).
So far my collection of functions that would do what we're after here (going from "2.67" to "2") is up to 3 or 4: