retain two decimal digits.
package kju.o;
import static kju.print.Printer.*;
import java.text.*;
class MathDemo
{
public static void main(String[] args)
{
double d = 1.2458;
println(round(d)); //prints:1.25
} static String round(double d)
{
DecimalFormat nf = new DecimalFormat("#.00");
return nf.format(d); //retain two decimal digits.
}
}
retain two decimal digits.的更多相关文章
- iOS Round Double value to 2 decimal digits and round 3rd decimal digit up
I have I double value like this one 17.125. It should be rounded up to 17.13 If I use the simple met ...
- java与C#用protobuf通信--java如何转换protobuf-net中的bcl.Decimal对象
公司内部有些C#服务使用proto-net,引入了bcl.proto中的bcl.Decimal.bcl.DateTime等.对于java的proto生成代码需要对bcl.Decimal.bcl.Dat ...
- poj 2720 Last Digits
Last Digits Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2233 Accepted: 474 Descri ...
- 2292: Quality of Check Digits 中南多校 暴力枚举
#include <cstdio> #include <algorithm> #include <cstring> #include <iostream> ...
- SqlBulkCopy Precision Error from C# Double to Sql Decimal?
https://forums.asp.net/t/1300113.aspx?SqlBulkCopy+Precision+Error+from+C+Double+to+Sql+Decimal+ Befo ...
- DECIMAL 数据处理原理浅析
注:本文分析内容基于 MySQL 8.0 版本 文章开始前先复习一下官方文档关于 DECIMAL 类型的一些介绍: The declaration syntax for a DECIMAL colum ...
- DecimalFormat详解
DecimalFormat继承自NumberFormat,可以使用它将十进制的数以不同形式格式化为字符串形式,可以控制前导和尾随0.前缀.后缀.分组(千).小数分隔符等,如果要更改格式符号(例如小数点 ...
- Sphinx 2.2.11-release reference manual
1. Introduction 1.1. About 1.2. Sphinx features 1.3. Where to get Sphinx 1.4. License 1.5. Credits 1 ...
- python2内置属性
# encoding: utf-8 # module __builtin__ # from (built-in) # by generator 1.145 from __future__ import ...
随机推荐
- 如何使用 Laravel Facades ?
Facade 布局是在面向对象编程中经常使用的一种软件设计布局方式.Facade 实际上是一种包括复杂函数库的类,提供了更加简洁易读的接口.Facade 布局还能为一组结构复杂.设计简陋的 API 提 ...
- iOS9 App Thinning(应用瘦身)功能介绍
iOS9 发布后,产生了一个使 App Thinning 无法正常运行的 bug.在iOS9.0.2 版本中,这个 bug 已经被修复,App Thinning 已经可以正常使用.当你从应用商店(Ap ...
- Java语言基础(二) Java关键字
Java语言基础(二) Java关键字 Java关键字比较多,我就不列举出来了,只记录一些常用的小知识点: ①Java的关键字只有小写. ②then.sizeof都不是Java的关键字,熟悉C++的程 ...
- 【POJ2396】Budget(上下界网络流)
Description We are supposed to make a budget proposal for this multi-site competition. The budget pr ...
- Android网络框架Volley(体验篇)
Volley是Google I/O 2013推出的网络通信库,在volley推出之前我们一般会选择比较成熟的第三方网络通信库,如: android-async-http retrofit okhttp ...
- C#针对DataTable进行分页方法
以下的分页方法是针对数据量不是非常大的数据进行的,是在内存中进行的分页操作. /// <summary> /// DataTable分页 /// </summary> /// ...
- tyvj P1952 Easy(递推+期望)
P1952 Easy 时间: 1000ms / 空间: 131072KiB / Java类名: Main 描述 某一天WJMZBMR在打osu~~~但是他太弱逼了,有些地方完全靠运气:(我们来简化一下 ...
- 像素,分辨率,PPI(像素密度),BPP 扫盲
像素于分辨率 像素,又称画素,为图像显示的基本单位,译自英文“pixel”,pix是英语单词picture的常用简写,加上英语单词“元素”element,就得到pixel,故“像素”表示“图像元素”之 ...
- hdu 4465 Candy(二次项概率)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4465 参考博客:http://www.cnblogs.com/goagain/archive/2012 ...
- linux —— 学习笔记(文件、文件夹操作)
目录:1.常用的文件文件夹操作 2.文件属性的设置 1.常用的文件文件夹操作 mkdir 创建文件夹 -p 如果指定 a/b/c 时 a .b 不存在,一起创建出来 cp 复制文件或文件 ...