I need to update some existing code , In order to ( Conditionally ) Display numbers without decimal places .
According to whether it is necessary to “£” The symbol uses the following two lines .
currency = string.Format(CultureInfo.CurrentCulture, "{0:£#,0.00}", data);
or
currency = string.Format(CultureInfo.CurrentCulture, "{0:#,0.00}", data);
I try to change this code to use {0:£#,0}, And after deleting the decimal places ,“ data ” value 23699.99 Round to 23700, instead of 23699.
I try to {0:£#,0} Try to understand what happened , And then again 23699.99 Round to 23700.
Can anyone explain why this happens ?
Thank you first .
Reference plan
When formatting numbers , It will always be rounded to the nearest number with the accuracy you choose . for example , If you set the format to one decimal place , be 0.86 Round to 0.9, and 0.96 Round to 1.0.
Again , If you print without decimal digits , be 23699.99 Round to 23700, because 23700 There is no decimal place closest 23699.99 The number of .
If you want to round , Please use Math.Floor.
Java Medium Boolean.valueOf(String) and BooleanUtils.toBoolean(String)? - javaI am here Boolean.valueOf(String) and BooleanUtils.toBoolean(String) There is a different problem between . I use my application like code BooleanUtils.toBoolean(defaultInfoRow.getFolderType()) equally , and Boolean.valueOf(defaultInfoRow.getFolderT…
Java string.hashcode() Provide different values - javaI have been on this issue for several hours . I've commented out all the code , Think this is related to the array out of range , But this is still happening . I'm trying to read input from a file using a scanner , Store the data and get it later using the hash code . But the hash value keeps changing .public static void main(String[] args) { //only prior code is to access data char…
string.split(“ _(B”) - javaBasically , This line of code doesn't work , I'm not sure why : String[] stringHolder = string.split("_(B"); I received this error : Indexes 3 This line of code is valid for nearby unclosed groups : String[] stringHolder = string.split("_B"); therefore , This makes me believe that it is caused by “(” Caused by the . Someone can tell me something like …
from PHP Get value from the array ? - phpWhen I use var_dump() When the function checks the value of an array .var_dump($data['content']); I have results array(1) { [0]=> array(10) { ["IDUser"]=> string(1) "1" ["Name"]=> string(5…
stay Map in , If we use existing keys to modify , Will not get ConcurrentModificationException - javaI have the following code , I hope from the situation 2 Throw... In the case of ConcurrentModificationException, But it runs successfully . as far as I am concerned , If I do the same for a single key in the map , No exception will be thrown , because here But when I reproduce this scenario with multiple keys in two cases , Modify by new key . Modify through the existing key . situation 1: Map<String,String> mp = new H…