Hi there, I was wondering if there is a similar function to format-number, but without rounding, so I don't have to create a custom one that involves string manipulation.
For example I have two values: let $x := <value>15.224134</value> let $y := <value>15.2249348734</value>
The following command will create different output for the two values (result for $x will be 15.224, result for $y will be 15.225)
format-number(xs:decimal($x), "0.000"))
Thanks,
George
Hi George,
I guess you’ll need to write an extra function:
declare function local:floor( $number as xs:decimal, $scale as xs:integer ) as xs:decimal { let $factor := xs:decimal(math:pow(10, $scale)) return floor($number * $factor) div $factor }; local:floor($y, <value>15.2249348734</value>)
Hope this helps, Christian
On Fri, Jan 13, 2017 at 2:16 PM, George Sofianos gsf.greece@gmail.com wrote:
Hi there, I was wondering if there is a similar function to format-number, but without rounding, so I don't have to create a custom one that involves string manipulation.
For example I have two values: let $x := <value>15.224134</value> let $y := <value>15.2249348734</value>
The following command will create different output for the two values (result for $x will be 15.224, result for $y will be 15.225)
format-number(xs:decimal($x), "0.000"))
Thanks,
George
basex-talk@mailman.uni-konstanz.de