首页 \ 问答 \ 直接优化JVM 和 Tomcat JVM优化有什么区别

直接优化JVM 和 Tomcat JVM优化有什么区别

更新时间:2022-08-31 21:08

最满意答案

2.9. Formatting Numbers and Currency
Problem
You want to format numbers or currency to control decimal places and commas, typically for printed output.
Solution
For basic number formatting, use the f string interpolator shown in Recipe 1.4:
scala> val pi = scala.math.Pipi: Double = 3.141592653589793

scala> println(f"$pi%1.5f")3.14159

A few more examples demonstrate the technique:
scala> f"$pi%1.5f"res0: String = 3.14159

scala> f"$pi%1.2f"res1: String = 3.14

scala> f"$pi%06.2f"res2: String = 003.14

If you’re using a version of Scala prior to 2.10, or prefer the explicit use of the formatmethod, you can write the code like this instead:
scala> "%06.2f".format(pi)res3: String = 003.14

A simple way to add commas is to use the getIntegerInstance method of thejava.text.NumberFormat class:
scala> val formatter = java.text.NumberFormat.getIntegerInstanceformatter: java.text.NumberFormat = java.text.DecimalFormat@674dc

scala> formatter.format(10000)res0: String = 10,000

scala> formatter.format(1000000)res1: String = 1,000,000

You can also set a locale with the getIntegerInstance method:
scala> val locale = new java.util.Locale("de", "DE")locale: java.util.Locale = de_DE

scala> val formatter = java.text.NumberFormat.getIntegerInstance(locale)formatter: java.text.NumberFormat = java.text.DecimalFormat@674dc

scala> formatter.format(1000000)res2: String = 1.000.000

You can handle floating-point values with a formatter returned by getInstance:
scala> val formatter = java.text.NumberFormat.getInstance ...

其他回答

你说呢...

相关问答

更多
  • 体育有32人 16% 20%
  • 2.9. Formatting Numbers and Currency Problem You want to format numbers or currency to control decimal places and commas, typically for printed output. Solution For basic number formatting, use the f string interpolator shown in Recipe 1.4: scala> val pi = ...
  • excel 统计百分比[2022-08-15]

    白班 =sumproduct((E3:E1000>=time(8,,))*(E3:E1000 评论0 3 0 加载更多
  • 您可以使用ANSI标准窗口函数(大多数数据库支持,包括SQL Server): Select persontype as PerSsonType, sum(fatalities_in_crash) as Total_Deaths, sum(fatalities_in_crash) * 1.0 / sum(sum(fatalities_in_crash)) over () as ratio from [CarCrash].[Source_Data_Staging] group by Perso ...
  • 以下代码将返回值列表: 成绩和分数 。 成绩将显示所有可用成绩,但是U. 分数值将显示相应成绩( 包括 U)的总百分比。 如果您希望得分为除 U 以外的成绩百分比,则以下SQL应该有效 SELECT grade, (COUNT(grade) * 100 / (SELECT COUNT(*) FROM studied WHERE grade !='U')) AS Score FROM studied WHERE grade !='U' GROUP BY grade 下面的屏幕截图显示了测试数据和查询结果 编 ...
  • 如果您不需要select distinct ,那么SQLZim的答案是正确的。 如果你这样做,那么你需要调整答案。 这是一种方式: select count(*) as RowCount count(distinct case when Active = 'Y' then id end) as ActiveCount, count(distinct case when Active = 'Y' then id end) * 1.0 / count(distinct id) fr ...
  • 这实际上是一个四舍五入的问题, lowerThanCount / length都是unit因此不支持小数位,因此任何自然百分比计算(例如0.2 / 0.5 )都会导致0 。 例如,如果我们假设lowerThanCount = 10 , length = 20 ,那么总和看起来就像 double result = (10 / 20) * 100 因此导致 (10 / 20) = 0.5 * 100 由于0.5不能表示为整数,所以浮点数将被截断,从而使您的0 ,因此最终的计算最终会变为 0 * 100 = ...
  • 迭代对象数组并在值更改时保持跟踪。 像这样的东西应该这样做: $oldvalue = false; // This is to exclude the first value from registering as a change $changes = 0; foreach($object_array as $obj) { if($oldvalue !== false && $obj->value != $oldvalue) $changes++; $oldvalue = $obj->va ...
  • 在SQL Server中,您可以使用: SELECT Attribute , COUNT(Attribute)*1.0 / SUM(COUNT(*)) OVER() * 100 AS TopIssues FROM Audits WHERE MONTH(TransActionDate) = MONTH(GETDATE()) GROUP BY Attribute ORDER BY COUNT(Attribute) DESC In SQL Server you can use: SE ...
  • 您必须派生自己的自定义控件并覆盖UpdateEditText()方法。 在我们处理它时,让我们覆盖默认的Minimum , Maximum和Increment属性值,使其更加符合百分比。 我们还需要覆盖基础ParseEditText()方法,将用户生成的输入解释为百分比(除以100),因为用户希望输入80代表80% (并且Decimal解析器需要忽略百分号)。 Public Class PercentUpDown Inherits NumericUpDown Private Shared ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。