社区
Java SE
帖子详情
easy thing!!!!!!!!!
JollySandy
2003-10-19 12:55:57
请问如何截取float或double型的小数位?-------急!!!!!!!!!!!!!!
...全文
29
5
打赏
收藏
easy thing!!!!!!!!!
请问如何截取float或double型的小数位?-------急!!!!!!!!!!!!!!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
5 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
老土豆T
2003-10-20
打赏
举报
回复
To: JollySandy()
你的方法和不错啊 (我脸红中。:)
Float.parseFloat(b);
Double.parseDouble(b);
JollySandy
2003-10-19
打赏
举报
回复
to all:
那么这样保留自然数E中的前4位小数可以吗?
String b = String.valueof(Math.E);
b = b.substring(1,6);
System.out.println(b);
如果我想把b再次转换成double型的话又应该如何做?
多谢!
alienbat
2003-10-19
打赏
举报
回复
1。强制赋值转换为整数(int)
2。把float型或者double型的数据减去上面得到的整数。
老土豆T
2003-10-19
打赏
举报
回复
一些偏方。。:)
float aaa =1212.1213;
int bbb= aaa % 1 ; //取整
float ccc= aaa-bbb ; //减去整,得到小数
String ddd =""+ccc ; //转化为字符串,将小数转化为字符串
SwordsmanF
2003-10-19
打赏
举报
回复
double a=1212.1213;
String b=String.valueOf(a);
b=b.substring(b.indexOf(".")+1,b.length());
System.out.println(b);
Easy
Mobile Pro 2.2.2
It takes care of these "necessary evils" so you can focus your time on doing the most important thing in game development: creating fun! This is the Pro version of
Easy
Mobile. Other version: EM ...
Easy
Mobile Pro 2.1.1
Easy
Mobile is a many-in-one package that greatly simplifies the implementation of standard features on every mobile game such as advertising, in-app purchasing, game services, notifications, sharing,...
Varian.SkinFactory.v1.01(2000)
The only thing left is to add a TSkin component to your form and load the script file. Now you are ready to release your first skinable application! The following features are currently available:- ...
Android代码-Virtual SoftKeys
A simple , safe and
easy
softKeys ( navigation bar). This project just was used for my device to solve hardware button problem. If you have any idea for any thing, please let me know! Features As ...
Android代码-albhedroid
re-implement this app the first thing I do whenever I'm learning a new language or platform. The reason is that it's fairly
easy
to do, but still involves common UI programming, event handling and ...
Java SE
62,614
社区成员
307,327
社区内容
发帖
与我相关
我的任务
Java SE
Java 2 Standard Edition
复制链接
扫一扫
分享
社区描述
Java 2 Standard Edition
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章