JAVA

public static void main(String[] args) {
DecimalFormat df = new DecimalFormat("###.##");
BigDecimal b1 = new BigDecimal("28.0109");
BigDecimal b2 = new BigDecimal("28.00");
System.out.println("小数格式化:" + df.format(b1)); //28.01
System.out.println("整数格式化:" + df.format(b2)); //28
}

C#

private static void Main(string[] args)
{
decimal a = 0.002m;
decimal b = 0.023m;
decimal c = 1.000m;
decimal d = 1.025m;
decimal e = 1.202m;
Console.WriteLine("a:" + a.ToString("###0.##")); //
Console.WriteLine("b:" + b.ToString("###0.##")); // 0.02
Console.WriteLine("c:" + c.ToString("###0.##")); //
Console.WriteLine("d:" + d.ToString("###0.##")); // 1.03
Console.WriteLine("e:" + e.ToString("###0.##")); // 1.2
}
<TextBlock Margin="5 9 0 0" Height="21" VerticalAlignment="Center">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} | {1} | {2} | {3} | {4:###0.####}{5} | {6:###0.####}{7}">
<Binding Path="drugName"></Binding>
<Binding Path="specification"></Binding>
<Binding Path="usage"></Binding>
<Binding Path="frequencyCode"></Binding>
<Binding Path="dosagePerTime"></Binding>
<Binding Path="dosageUnit"></Binding>
<Binding Path="quantity"></Binding>
<Binding Path="quantityUnit"></Binding>
</MultiBinding>
</TextBlock.Text>
</TextBlock>

Text="{Binding realQuantity, Mode=OneWay,StringFormat={}{0:###0.####}}"

小数末尾是0的,不显示0,有值才显示 StringFormat的更多相关文章

  1. Group By Count不能显示0的问题

    问题: 如对表: /*==================================================== id |score |grade ------------------- ...

  2. MiniProfiler.3.0.10 用于MVC4.0中不能显示SQL语句

    MiniProfiler.3.0.10 用于MVC4.0中可以显示执行时间,但是不能显示SQL语句,怎么解决?

  3. 动态IP无法获取默认网关,显示0.0.0.0的解决办法

    IP地址使用自动获取IP方式,可以获取到IP地址和子网掩码,默认网关无法获取,显示0.0.0.0,通过修复Winsock和LSP可以解决该问题,具体步骤如下:一.修复winsock1.单击开始> ...

  4. 定义一个复数(z=x+iy)类Complex,包含: 两个属性:实部x和虚部y 默认构造函数 Complex(),设置x=0,y=0 构造函数:Complex(int i,int j) 显示复数的方法:showComp()将其显示为如: 5+8i或5-8i 的形式。 求两个复数的和的方法:(参数是两个复数类对象,返回值是复数类对象)public Complex addComp(Compl

    因标题框有限,题目未显示完整,以下再放一份: 定义一个复数(z=x+iy)类Complex,包含: 两个属性:实部x和虚部y 默认构造函数 Complex(),设置x=0,y=0 构造函数:Compl ...

  5. ZOJ 3962 Seven Segment Display 16进制的八位数加n。求加的过程中所有的花费。显示[0,F]有相应花费。

    Seven Segment Display Time Limit: Seconds Memory Limit: KB A seven segment display, or seven segment ...

  6. 路由器wan口ip地址显示0.0.0.0怎么办

    http://m.xuexila.com/luyouqi/671049.html 这个网络时代里面我们最常用来连接网络的设备就是路由器了,现在的社会不管是工作还是生活几乎都离不开网络了,同时我们也要学 ...

  7. Python3.0 调用HTMLTestRunner生成的报告中不能显示用例中print函数的输出

    官方原生的HTMLTestRunner.py支持python2.0版本,python3.0版本的使用需要做一些修改: Python3调用HTMLTestRunner执行用例生成测试报告中,不能正常显示 ...

  8. 数码管显示“0~F”的共阳共阴数码管编码表

    嵌入式设备中数码管显示“0~F”的方式是:定义了一个数组,里面含有16个元素,分别代表0~F,这样可以方便以后的调用.共阳极数码管编码表:unsigned char table[]={0xc0,0xf ...

  9. ubuntu 16.04 +anaconda3.6 +Nvidia DRIVER 390.77 +CUDA9.0 +cudnn7.0.4+tensorflow1.5.0+neural-style

    这是我第一个人工智能实验.虽然原理不是很懂,但是觉得深度学习真的很有趣.教程如下. Table of Contents 配置 时间轴 前期准备工作 anaconda3 安装 bug 1:conda:未 ...

随机推荐

  1. storm整合kafka storm-kafka-client

    pom.xml-注意jar-log4j---------------------<dependencies> <dependency> <groupId>org.a ...

  2. mysql数据库总结。

    mysql MySQL语法MySQL采用结构化查询语言SQL (Structured Query Language)语言来操作数据库SQL语句必须以 ; 结束SQL语句分类DDL(数据定义语言): c ...

  3. Codeforces C. Split a Number(贪心大数运算)

    题目描述: time limit per test 2 seconds memory limit per test 512 megabytes input standard input output ...

  4. VMware下安装的CentOS7.5,设置成静态IP后ping不通外网

    网上很多都说用下面的方法即可解决 在CentOS中 ping www.baidu.com 无法ping通,可能原因是DNS没配置好 方法一: 修改vim /etc/resolv.conf 增加如下内容 ...

  5. vue 修改对象或数组的属性

  6. AST11103 Problem Solving

    AST11103 Problem Solving with Programming SkillsAdditional Individual Assignment: Min-Game Programmi ...

  7. 详解如何在CentOS7中使用Nginx和PHP7-FPM安装Nextcloud

    转载地址:https://www.jb51.net/article/109382.htm 这篇文章主要介绍了详解如何在CentOS7中使用Nginx和PHP7-FPM安装Nextcloud,会通过 N ...

  8. (尚019)Vue基于脚手架编写项目

    vue_demo目录结构截图: (1)图一 (2).图二 (3).图三 (四).图四 (5).图五 (6).图六 (7).图七 不能随便改入口文件的名字,因为已经配置好了 (8).图八 (9).图九 ...

  9. Java web开发——文件的上传和下载

    一. 功能性需求与非功能性需求 要求操作便利,一次选择多个文件和文件夹进行上传:支持PC端全平台操作系统,Windows,Linux,Mac 支持文件和文件夹的批量下载,断点续传.刷新页面后继续传输. ...

  10. A revolutionary architecture for building a distributed graph

    转自:https://blog.apollographql.com/apollo-federation-f260cf525d21 What if you could access all of you ...