PB_Truncate函数截取小数点引起的数字错误
参考PB帮助中Truncate函数的说明:
Using Truncate on a computed field A real number loaded into a floating point register (used for calculation) is represented as precisely as the binary storage will permit. For example, the real number displayed as 2.07 is actually stored as 2.0699999999999997.
Truncating such a number may not give the expected result. To avoid this problem, you can change the initial real data type to long, integer, or decimal, or you can append a constant in the truncate argument: Truncate (x + 0.0000001, n )
xg1=dec(left(mpart[8],4))
gonglv=truncate(xg1 / 100,2)
注意,这里的xg1如果是int类型的话,就会发生上面的错误,将其类型修改为DEC后,解决!