我正在使用XQuery中的一些数学函数来推断未来10年的人口增长,如下所示:
let $db := doc("mondial.xml")
for $country in $db/mondial/country
let $last_pop := $country/population[last()]
let $snd_last_pop := $country/population[last() - 1]
let $pop_growth := $last_pop div $snd_last_pop
let $yt2026 := 2026 - $last_pop/@year
return <country>
{$country/name}
<population year="2026" measured="extrap.">{
$last_pop * math:exp($yt2026 * math:log($pop_growth))
}</population>
</country>然而,我的输出要么是科学符号,要么是小数点的很多位。
<country>
<name>Albania</name>
<population year="2026" measured="extrap.">706860.8616776819</population>
</country>
<country>
<name>Greece</name>
<population year="2026" measured="extrap.">9.19404785580711E6</population>
</country>
<country>
<name>Macedonia</name>
[...]使用xs:int()会产生一个错误。
如何用整数表示这些值?(这个符号叫什么名字?“正常表示法”
发布于 2016-03-31 15:59:59
您可以使用format-number(9.19404785580711E6, "0")实现不带小数位的非科学输出。该值在返回之前是四舍五入的,因此给定语句的结果是9194048。
https://stackoverflow.com/questions/36337725
复制相似问题