本文介绍了在java中获取双数的小数部分的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我有一个双号。 double n = 47758.35; 为了得到这个数字的小数部分我做了如下 long decPart =(long)((n-Math.floor(n))* 100); 在大多数情况下,我得到正确的小数部分,但在这种情况下,decPart变为 34 QUOT;而不是35 我怎样才能得到确切的小数部分 请帮助解决方案 您可以将其拆分为字符串 展开 | 选择 | Wrap | 行号 使用 展开 | 选择 | Wrap | 行号 Ive got a double number. double n=47758.35;Inorder to get the decimal part of this number i did as follows long decPart = (long) ((n-Math.floor(n))*100); in most cases i get the correct decimal part but in this case the decPart becomes"34" instead of "35" how can i get the exact decimal part Please Help 解决方案 You can split it up as string Expand|Select|Wrap|Line NumbersUse Expand|Select|Wrap|Line Numbers 这篇关于在java中获取双数的小数部分的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-13 14:52