English 中文(简体)
如何在不失去所有零点的情况下分数?
原标题:How to divide a number without losing all the zero s?
  • 时间:2011-10-06 06:02:20
  •  标签:
  • groovy

在大饥荒中,我有这样的法典:

def a = 44000
println a/10000​

产出<条码>4.4>。 但删除了<代码>4后的所有零件。 出于某种原因,希望产出为4.4000。 粗略地说,我们如何能够做到这一点?

最佳回答

享有4.4项权利的权利没有重大零,这并不是说它没有显示这些权利,而是没有任何 are。

你们拥有的是严格的格式问题。 为了将4.4改为4.4万瑞士法郎,你可以做到:

def a = 44000
println String.format(  %.4f , a / 10000 )
问题回答

暂无回答




相关问题
Groovy - how to exit each loop?

I m new to Grails/Groovy and am trying to find a node in a an xml file; I ve figured out how to iterate over all of them, but I want to exit the loop when the target node is found. I ve read that ...

Eclipse Spring Builder set properties with Groovy beans

I typically use groovy to construct simple bean but the Spring IDE plugin to eclipse fails to build when I try to set a property that is generated by groovy without an explicit setter. For example, ...

How can I get this snippet to work?

I d like to port a little piece of code from Ruby to Groovy, and I m stuck at this: def given(array,closure) { closure.delegate = array closure() } given([1,2,3,4]) { findAll { it > 4} ...

Changing the value in a map in Groovy

This is about a very basic program I m writing in Groovy. I have defined a map inside a method: def addItem() { print("Enter the item name: ") def itemName = reader.readLine() print(...

Is functional Clojure or imperative Groovy more readable?

OK, no cheating now. No, really, take a minute or two and try this out. What does "positions" do? Edit: simplified according to cgrand s suggestion. (defn redux [[current next] flag] [(if flag ...

热门标签