easy thing!!!!!!!!!

JollySandy 2003-10-19 12:55:57
请问如何截取float或double型的小数位?-------急!!!!!!!!!!!!!!
...全文
30 5 打赏 收藏 转发到动态 举报
写回复
用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);
游戏出海快速对接广告平台工具包 unity跨平台多功能手机游戏工具包Easy Mobile Pro v2.2.2 所支持的Unity版本:5.5.5 及以上版本 With version 2.2.0, we introduce the hugely awaited feature: multiplayer! This makes Easy Mobile Pro the first Unity plugin ever to offer a truly cross-platform API for Turn-Based and Real-Time multiplayer on iOS and Android - one that not only combines, but actually unifies the native APIs to create a single API and a single workflow for developing multiplayer games that work for both iOS and Android! 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, etc. 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 Basic * See the feature comparison image for differences between EM Pro and EM Basic. ? HIGHLIGHTS ? Cross-platform: intuitive, cross-platform API that can accomplish most tasks with a single line of code. ? Friendly Editor: beautiful & easy-to-use editor for controlling everything from one place. ? Automation: automating chores such as service initialization and ad loading. ? Modular Design: use only what are needed and not be worried about redundancies or contradictions with existing code. ? Leveraging Official SDKs: to form a coherent system that maximizes usability and reliability - without reinventing the wheel!

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧