插入特定算术值时溢出
我目前正在使用 java 中的 JSON 变量的数据从 Word 模板生成 Word 文档文件。我正在使用 ASPOSE 库。
我对特定变量有疑问。该变量应该打印一个数字(浮点)值。但是,当值为 100.0 时,有时会打印为 -2147483648 (-2^31) 而不是 100.0。
我不得不提的是,当该值为两位数浮点数(例如 35.5 和 99.9)时,变量的值会正确打印。另外,当输入值为整数(例如100)时,也会正确打印正确的值。
我还尝试在Word模板文件中的表达式标记内使用一些格式字符串(<<[variableName]:"0.##">>),但它没有修复它。
I'm currently working on generating a Word document file from a Word Template using data from a JSON variable in java. I'm using the ASPOSE library.
I have a problem with a specific variable. This variable should print a numeric(float) value. However, when the value is 100.0 ,it is sometimes printed as -2147483648 (-2^31) instead of 100.0.
I have to mention that when the value is a double digit float (for example 35.5 and 99.9),the value of the variable is printed correctly. Also when the input value is integer(e.g 100),the correct value is also printed correctly.
I have also tried to use some format strings(<<[variableName]:"0.##">>) inside the expression tag in the Word Template file, but it didn't fix it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
@aggelos991
使用最新版本的 Aspose.Words for Java(即 22.2),我无法重现该问题。此外,我们有 过去有类似的问题,所以看来您正在使用过时版本的 Aspose.Words爪哇。您能否升级到最新版本并告知我们问题是否仍然存在?
@aggelos991
Using the latest available version of Aspose.Words for Java (i.e. 22.2), I was unable to reproduce the issue. Moreover, we had a similar issue in the past, so it seems like you are using an outdated version of Aspose.Words for Java. Could you please upgrade to the latest version and let us know if the issue is still present?
Float 类型为 32 位格式,100.0 为 64 位格式(double)。正确使用时必须使用 100.0f。
Float type is in the 32bit format, and 100.0 is in the 64bit format(double). 100.0f must be used for proper use.