number-formatting

Masking numbers in PrimeFaces footerText column Datatable

守給你的承諾、 提交于 2019-12-09 17:35:02
问题 I want to display a masked number like this: 1.234.567,89. The following code already do this: <p:column> <h:outputText value="#{item.value}"> <f:convertNumber locale="pt_BR"/> </h:outputText> </p:column> How can I applly the same mask for a Primefaces datatable in a footerText column as the following code excerpt? <p:columnGroup type="footer"> <p:row> <p:column colspan="8" footerText="Grand Total:" /> <p:column footerText="#{upbController.totalLosses}" /> </p:row> </p:columnGroup> Thanks in

Why does .NET decimal.ToString(string) round away from zero, apparently inconsistent with the language spec?

喜夏-厌秋 提交于 2019-12-09 14:14:30
问题 I see that, in C#, rounding a decimal , by default, uses MidpointRounding.ToEven . This is expected, and is what the C# spec dictates. However, given the following: A decimal dVal A format string sFmt that, when passed in to dVal.ToString(sFmt) , will result in a string containing a rounded version of dVal ...it is apparent that decimal.ToString(string) returns a value rounded using MidpointRounding.AwayFromZero . This would appear to be a direct contradiction of the C# spec. My question is

Force leading zero in number input

吃可爱长大的小学妹 提交于 2019-12-09 00:27:37
问题 I'm writing an alarm web app. I have two number inputs, one for the hours, one for the minutes. Thus, when I use my keyboard arrows, they go from 0 to 23/59. Is there an HTML native way to make them go from 00 (01,02, et.) to 23/59 instead ? I'm only worried about the UI aspects as my JS manages the missing 0 anyway. EDIT - As requested : What I have : What I want : Instead of going from 0,1,2 to 59, I'd like to automatically have a leading 0 when the number is smaller than 10 (00,01,02 to 59

Use comma instead of dot for decimals when saving as text

早过忘川 提交于 2019-12-08 22:31:06
问题 This question looks similar to Visual basic handle decimal comma, but that one is about an entirely different problem. I am writing a VBA macro to save my Excel file to a .txt file. This code line was generated by actually recording a macro where I saved the file to .txt : ActiveWorkbook.SaveAs Filename, FileFormat:=xlText Now, the issue is that the .txt file has all decimals formatted with dots, while I require them to be commas. For instance, it writes 32.7 while I am expecting 32,7 . Some

How do Europeans write a list of numbers with decimals?

我的未来我决定 提交于 2019-12-08 21:01:05
问题 As I understand it, Europeans(*) write numbers with a comma for a decimal separator, so one-and-a-quarter is written as 1,25 Europeans also use commas to separate lists, so how do you write a list of decimal numbers? I, as an Englishman, would write one-and-a-quarter, one-and-a-half, one-and-three-quarters like this: 1.25, 1.5, 1.75 How do you do that in Europe? (Why is this a programming question? Because I'm writing a program that will ask European users for a list of numbers!) * For the

Formatting a column with EPPLUS Excel Library

被刻印的时光 ゝ 提交于 2019-12-08 15:35:11
问题 I wrote a C# program to create an excel spreadsheet. The sheet has multiple columns. I want to format ONE of the columns. aFile = new FileInfo(excelDocName); // excelDocName is a string ExcelPackage pck = new ExcelPackage(aFile); var ws = pck.Workbook.Worksheets.Add("Content"); ws.View.ShowGridLines = true; ws.Cells["B:B"].Style.Numberformat.Format = "0.00"; ws.Cells[1, 1].Value = "AA"; ws.Cells[1, 2].Value = "BB"; ws.Cells[1, 3].Value = "CC"; ws.Cells[1, 4].Value = "DD"; for (int row = 2;

Angular calculate percentage in the html

▼魔方 西西 提交于 2019-12-08 15:07:03
问题 Angular noob here! I am trying to display a percentage value in my html as follows: <td> {{ ((myvalue/totalvalue)*100) }}%</td> It works but sometimes it gives a very long decimal which looks weird. How do i round it off to 2 digits after the decimal? Is there a better approach to this? 回答1: You can use the toFixed method of Number . ((myValue/totalValue)*100).toFixed(2) 回答2: You could use a filter, like this one below by jeffjohnson9046 The filter makes the assumption that the input will be

How to format numbers in scientific notation with powers in superscript

不打扰是莪最后的温柔 提交于 2019-12-08 14:48:38
问题 I need to write values like: 9.6 x 10² 9.6 x 10¹² I need to know if there is a way to format numbers as above in a string. 回答1: As a follow up to my comment above - does something like this do what you require : public String FormatAs10Power(decimal val) { string SuperscriptDigits = "\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079"; string expstr = String.Format("{0:0.#E0}", val); var numparts = expstr.Split('E'); char[] powerchars = numparts[1].ToArray(); for (int i = 0; i <

How to format numbers as strings to be in the form “xxx.xxx.xxx,yy”in Java?

家住魔仙堡 提交于 2019-12-08 12:08:55
问题 is there a class in Java that lets you format a number like "102203345.32" to this "102.203.345,32" and return a string type? I would like to obtain a String where the thousands are separated by the '.' and the decimals are separated by a comma ','. Could someone help me please? I found a class DecimalFormat and I tried to customize it: public class CustomDecimalFormat { static public String customFormat(String pattern, double value ) { DecimalFormat myFormatter = new DecimalFormat(pattern);

PHP - number_format issues

我的梦境 提交于 2019-12-08 08:54:12
问题 number_format stupidly rounds numbers by default. Is there just a simple way to turn off the rounding? I'm working with randomly generated numbers, and I could get things like... 42533 * .003 = 127.599 or, 42533 * .03 = 1275.99 or, 42533 * .3 = 12759.9 I need number_format (or something else) to express the result in traditional U.S. format (with a comma separating the thousands) and not round the decimal. Any ideas? 回答1: The second argument of number_format is the number of decimals in the