Sen*_*cob 1 c# types decimal rounding primitive-types
我有一个奇怪的问题.我试图将一个十进制变量分配给SAP Web服务.但是我得到CX_SY_CONVERSION_LOST_DECIMALS
小数超过限制的错误.
我通过使用Math.Round(Decimal,Int32)方法解决了它
这是我的疑问.
i = 1.23450M;
j = Math.Round(i, 2); // 1.23M
Run Code Online (Sandbox Code Playgroud)
(i!= j)== true,因为该值有差异
i = 1.000000M;
j = Math.Round(i, 2); // 1.00M
Run Code Online (Sandbox Code Playgroud)
我可以j
在Web服务中分配给该字段,但不能i
.现在i
和j
?之间有什么区别?为什么会这样?
有关WSDL的参考,请忽略主题.
<xsd:element name="MyVar" type="tns:curr15.2" />
<xsd:simpleType name="curr15.2">
<xsd:restriction base="xsd:decimal">
<xsd:totalDigits value="15" />
<xsd:fractionDigits value="2" />
</xsd:restriction>
</xsd:simpleType>
Run Code Online (Sandbox Code Playgroud)