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 ...
随机推荐
- 转:synchronized和LOCK的实现原理---深入JVM锁机制
JVM底层又是如何实现synchronized的? 目前在Java中存在两种锁机制:synchronized和Lock,Lock接口及其实现类是JDK5增加的内容,其作者是大名鼎鼎的并发专家Doug ...
- C语言头文件的使用与写法
C语言中的.h文件和我认识由来已久,其使用方法虽不十分复杂,但我却是经过了几个月的“不懂”时期,几年的“一知半解”时期才逐渐认识清楚他的本来面目.揪其原因,我的驽钝和好学而不求甚解固然是原因之一,但另 ...
- Linux Shell编程(22)——时间/日期 命令
date直接调用, date 就会打印日期和时间到 stdout 上. 这个命令有趣的地方在于它的格式化和分析选项上.time输出统计出来的命令执行的时间.touch这是一个用来更新文件被存取或修改的 ...
- Windows进程
一.Windows进程 1.进程 进程是一种容器,包含了应用程序实例的各种资源. 2.Windows进程的一些特点 2.1.进程中包含了执行代码等资源 2.2.进程都具有私有的地址空间 2.3.每个进 ...
- Scrapinghub | Professional Services
VShell破解版 VShell破解版 Scrapinghub | Professional Services OUR PROFESSIONAL SERVICES INCLUDE
- UVA 753 - A Plug for UNIX(网络流)
A Plug for UNIX You are in charge of setting up the press room for the inaugural meeting of the U ...
- Unity3D 制作右上角小地图
一个简单的方法, 首先先在俯视图视角截取一张图片,用作小地图的背景图片.然后新建一个Plane,把截图附到Plane上,然后把Plane与刚才截图的场景的相应位置重合,要尽量重合,当做地图.(见 ...
- Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level(转)
[问题] 一个python脚本,本来都运行好好的,然后写了几行代码,而且也都确保每行都对齐了,但是运行的时候,却出现语法错误: IndentationError: unindent does not ...
- [置顶] js正则表达式的使用
js中的正则表达式比起C#中的正则表达式要弱很多,但基本够用了 1定义正则表达式 2关于验证的三个这则表达式方法 3正则表达式式的转义字符 1定义正则表达式 在js中定义正则表达式很简单,有两种方式, ...
- DataTable无法使用AsEnumerable ()的解决办法
本人定义了DataSet后将表1赋给datatable,在写linq时调用datatable.asenumerable(),但报datatable不包含asenumerable的定义,求高手指点.Sy ...