What is the use of a negative picture?

What is the use of a negative template?

NumberFormat nf = NumberFormat.getPercentInstance(Locale.ITALY); DecimalFormat df = (DecimalFormat)nf; df.applyPattern("###,###.###;(###,###.###)"); System.err.println(df.format(-12.45));//output (12,45); 

In which scenario would this be useful? Is this not just a module?

+4
source share
2 answers

A negative pattern is just another way to print negative numbers. You may need a wide selection of options:

  1,234 1,234 1,234 1,234 CR -1,234 1,234- (1,234) 1,234 DR 

etc. Each of them is useful in different areas. Option (1,234) is actually quite useful if you do not have a color printer, since it stands out much more than just the main negative, and it is often used in the areas of accounting and accounting.

My own favorite (in a setting other than Java, Libre Office):

 "#,##9.99 ;[RED](#,##9.99-)" 

which displays negative numbers in red with a terminating character - and is surrounded by brackets, so there is no doubt about its negative value:

enter image description here

+8
source

Believe it or not, I saw several business applications that format their negative values ​​in this way. Therefore, I am afraid that this is so, because people need / use it.

+3
source

Source: https://habr.com/ru/post/1502025/


All Articles