How are we doing? Please help us improve Stack Overflow. Take our short survey

Questions tagged [number-formatting]

Number formatting is the process of converting a numeric value into a string suitable for display. Things to take into account are the decimal/thousands separator, digit grouping, the shape of the numbers, how a percentage or currency is displayed, and so on.

number-formatting
552 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
3k views

OpenCsv: Can I specify the locale once instead of repeating it in every @CsvBindByName?

I'm using OpenCSV to parse csv files which needs to work when run in both the UK and Germany. When parsing numbers we need to specify the locale so that OpenCSV knows which decimal separator ('.' for ...
lance-java's user avatar
  • 26.9k
6 votes
1 answer
273 views

NumberFormatter with singular / plural word

Is it possible to use PHP NumberFormatter class to display words in singular or plural depending on the number value using the setPattern method? This method is using the ICU DecimalFormat library, ...
Seb33300's user avatar
  • 7,535
6 votes
0 answers
598 views

Cardinal numbers with NumberFormatter using Locale settings in Swift

How can I generate cardinal numbers(One, Two, Three) using NumberFormatter in Swift using Locale settings. For example, I am able to convert 1 minute -> One minute using English Locale settings. ...
Umair Aamir's user avatar
  • 1,644
6 votes
3 answers
3k views

Java NumberFormat ignoring comma in US locale ?

I don't understand something in the NumberFormat, in US locale it is suppose to treat comma (",") as a group separator - for thousands. Why does it ignore commas in incorrect places for this locale ? ...
Yoni's user avatar
  • 385
5 votes
0 answers
135 views

How to round float numbers in Haskell just like in C using printf?

I have a simple code to read a float number and print it with six decimal places. I have my C code working and I want to make an equal one to Haskell language without installing any extra library. My ...
eightShirt's user avatar
  • 1,451
5 votes
0 answers
119 views

How do I print floats with specified number of decimals and locale specific separators in Python?

I'm writing an application that needs to handle a fixed number of decimal places for floating-point numbers, which is easy enough with the f presentation type. >>> f'{1.1:.2f}' '1.10' I also ...
Javier Gostling's user avatar
5 votes
1 answer
1k views

Why is .NET "de-CH" culture number group separator different locally and on Azure?

I am seeing a different Unicode character as the number group separator for the "de-CH" culture when running on a local desktop and in Azure. When the following code is run on my desktop in ....
Josh Gallagher's user avatar
4 votes
0 answers
2k views

Python - Spyder Dataframe Float Format Variable Explorer with thousands separator

I want to know if it's possible to change the Spyder DataFrame float format in the variable explorer to include the thousands separator? I am not talking about when you use print().format , that is ...
YoungFella's user avatar
4 votes
1 answer
562 views

Have I found a bug in PHP's NumberFormatter's "formatCurrency" function?

I happen to know for a fact how the "SEK" (Swedish money) currency is supposed to be formatted in "SE" (Sweden) locale with "sv" (Swedish) language. It's supposed to be using periods for thousands ...
user avatar
4 votes
0 answers
1k views

Angular/Typescript numeral.js

I want to format a number to also display the Romanian format for decimals and thousands like this: 1.000,23 . I am using the numeral.js library. Here is my pipe code: constructor(private session: ...
TudorPopescu's user avatar
4 votes
2 answers
540 views

How can I convert a float in a str without losing significant figures?

I want to convert the number 0.054000 in a str, but when I write srt(0.054000) I get '0.054'. I need to get '0.054000'. How can I do it? I have a data file with numbers as my example (0.054000). I ...
Danny Alzate's user avatar
4 votes
1 answer
1k views

Fixed-point number format specifier rounding of doubles?

I have a pretty decent understanding of IEEE 754 so this is not one of those "why does adding number a and number b result in..."-type of questions. Rather I want to ask if I've understood the fixed-...
AnorZaken's user avatar
  • 1,986
4 votes
0 answers
15k views

Php Excel Number Formatting

I have this code to format the cell in number format, $objPHPExcel->getActiveSheet() ->getStyle($colmun_alpha[$total_head+1].$row_total) ->getNumberFormat() ->setFormatCode('#...
Yassi's user avatar
  • 2,479
4 votes
1 answer
765 views

Display large number in compact notation in i18n compatible way (ex: display 122025999 as 122M or 1.2億) across browsers

Need a cross browser compatible way to display compact notation for large numbers, very similar to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat with ...
naeohmi's user avatar
  • 41
3 votes
0 answers
94 views

Is this a bug with PHP's NumberFormatter::SPELLOUT? Can it be made smarter/less strict?

Example code: function number_from_spelledout_number($number_string) { $a = new \NumberFormatter('en_US', \NumberFormatter::SPELLOUT); return $a->parse($number_string); } var_dump(...
user16508174's user avatar
3 votes
0 answers
52 views

Display numbers as localised words (.NET 5)

I want to display numbers as localised words (11 == Eleven, Onze, Elf depending on language). I know that .NET 5 uses the ICU library "under the hood" and that ICU has this capability, but I ...
Michael Kay's user avatar
3 votes
1 answer
3k views

QML: Formatting a number with varying precision and without exponent

In QML, I can format a number using Number.toLocaleString() (where my default locale is en_US); however, when given zero parameters, its behavior curiously isn't the same as what is documented, though ...
Adam Gausmann's user avatar
3 votes
3 answers
521 views

NumberFormatter: strange behaviour with a minus sign in different locales

I came across a problem with Symfony/Form which under the hood use NumberFormatter to format NumberType field. Our project is multilingual and for each country, we use a different locale. $formatter-&...
Serhii Popov's user avatar
  • 3,635
3 votes
0 answers
351 views

When and why did the Swedish locale(s) change from formatting money sums between these formats?

I was one of the few people who bothered to learn how to format numbers and money sums. It used to be, and I thought it was still, like this: 123 456 789,00 123.456.789,00 The first one is a non-...
user avatar
3 votes
0 answers
228 views

Number format in Word document

I have some fields in an Word document with instructional text, for example like this one: { MERGEFIELD MyField1 \# "000" } I'm reading those fields using OpenXML SDK, as shown here, and ...
hertzogth's user avatar
  • 326
3 votes
1 answer
638 views

How to set number format in Table with pandastable

I'm writing a GUI with tkinter and it's using pandastable module to display a dataframe. I'm trying to get this number format in the pandastable's Table: pd.options.display.float_format = '{:,.4f}'....
Van Vi's user avatar
  • 41
3 votes
1 answer
10k views

Adjust number formatting in Excel via xlwings from python

I have started using xlwings to create an excel tool which calls a python code. I think it is super useful and at the same time user-friendly as everybody is used to have excel as GUI. Now to my ...
Philipp's user avatar
  • 31
3 votes
0 answers
1k views

Use custom number format (exponential with custom suffix) on Kendo numeric textbox

I am trying to have a custom format on a kendo numeric textbox so that the number displays in exponential format with a text string after it. For example the format-string used by Kendo's Number ...
PedroPod's user avatar
3 votes
1 answer
1k views

how to format amounts in indian format in google chart

My Graph is like this: I want to show amounts like indian format instead of Million/Billion i want to show Thousand/Lakhs/Crores and also in tooltip as "27,98,99,811.34" thanks in advance..
Ravi Sargam's user avatar
3 votes
1 answer
387 views

.net: What is the correct format string for a fixed number of decimal places, but "x.xxE+xxx" for large numbers?

I want to format double values with a fixed number of four decimal places. What I want: "Small" numbers should be displayed in whole, i.e., 1234.56789 should be displayed as 1234.5679 "Large" numbers ...
rabejens's user avatar
  • 7,862
3 votes
1 answer
889 views

How to format a math expression inside a text field?

I'm creating a Calculator software. In the text field as I'm typing, the whole expression appears as one string (and I want to keep it this way). Here's a demo: I want it to be formatted like this: ...
Marko Kitonjics's user avatar
3 votes
0 answers
236 views

Is it possible to set PercentPositivePattern in Windows UI?

In an application that is internationalized, I have code like this: _comboBlah.Items.Add(pct.ToString("P0", formatInfo)); where formatInfo is normally from the CultureInfo for the current UI ...
Tom Bogle's user avatar
  • 481
3 votes
2 answers
7k views

Html.EditorFor for a decimal field with commas

Hi I have a decimal field defined for price as follows: [Required(ErrorMessage = "Asking Price/Rent is required.")] [Display(Name = "Asking Price/Rent*")] [DisplayFormat(DataFormatString = "{0:N0}", ...
Tripping's user avatar
  • 919
2 votes
1 answer
211 views

How can I differentiate decimal comma and decimal point on my js calculator?

Like I've written in the title I would like to differentiate this 2 kinds of decimal in my js calculator because they mean two different things. I tryed to read around and I found something about ....
91Flavio91's user avatar
2 votes
0 answers
25 views

Percent Sign within JFormattedTextField appears spaced differently between Linux and Windows

On Linux, the percent sign appears separated from the corresponding value within a JFormattedTextField. Like this: 123,0000000000 %. On the other hand, on Windows, it's displayed attached to the value:...
jupiter_jazz's user avatar
2 votes
0 answers
829 views

Change IXLCell number format from decimal point (.) to decimal comma (,) - c#

So it's pretty simple..(at least I thought so...) I'm trying to export some data to excel from my app and I can't find a solution how to change decimal point to decimal comma (this is also an European ...
user3746480's user avatar
2 votes
0 answers
266 views

Format numeric value of validation message in Laravel

I wonder if there is anyway to format the numeric value of Laravel validation messages. For example, the validation rule 'min': 'min' => [ 'numeric' => 'The :attribute must be at least :min.'...
Tommy Hoang's user avatar
2 votes
0 answers
345 views

adding page numbers to the output of pdfjam

I'm using pdfjam to output 2x2 versions of a pdf file. Is there a way to add page numbers to the output of the reduced pdf. That is, if I had a 28page pdf, reduced it to 7 2x2 pages, the ...
Leo Simon's user avatar
  • 186
2 votes
1 answer
1k views

How to force decimals in flutter's Numberformat.compactCurreny?

I'm trying to get a human comprehensive monetary value. Being that value 100000 it returns 100K Being that value 100500 it returns 101K when I would like to get 100.5K Note that I'm using the intl ...
Dunnow's user avatar
  • 414
2 votes
2 answers
853 views

How do I validate if the number is in proper format with respect to the locale while using Intl.numberFormat in java script?

I'm using Intl.numberFormat, And not able to check if the number entered by the user is in proper format for that locale, like comma separated, dot separated and space separated for some countries.
Madhu mitha's user avatar
2 votes
1 answer
74 views

Regex: change strings of numbers to standard parseable format

I am trying to wirte a replacer function that will take a string and if it identifies it as a number, will change it into a standard format number (that is parseable in most languages) Is it possible ...
Aneta's user avatar
  • 31
2 votes
0 answers
226 views

C# Get custom number format from standard format

I need to get the custom format from a standard format as defined here https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings E.g. "D6" => "000000" For DateTime ...
wertzui's user avatar
  • 5,468
2 votes
0 answers
2k views

In Surv(start_time, end_time, new_death) : Stop time must be > start time, NA created

I am using the package "survival" to fit a cox model with time intervals (intervals are 30 days long). I am reading the data in from an xlsx worksheet. I keep getting the error that says my stop time ...
user2105874's user avatar
2 votes
0 answers
657 views

Why do the prefixes and suffixes of certain Java currency formats end with a space-like character instead of space?

I'm retrieving all available Java currency formats as follows: for(Locale locale : Locale.getAvailableLocales()) { for(Currency currency : Currency.getAvailableCurrencies()) { ...
Kalle Richter's user avatar
2 votes
1 answer
578 views

Converting between RFID output types?

I have an RFID reader hooked up to a Arduino and one that goes to a PC. The PC one has options to output in different formats. I have this code for my Arduino: // interrupt that happens when INTO ...
James Sedman's user avatar
2 votes
0 answers
112 views

Prevent converting a Single to the Scientific Numbers format

There is Dim sValA as Single sValA = 10140000 When I perform: Debug.Print sValA, Returns: 1.014E+07 I need never converting a Single number to the scientific format. (Means: 10140000 should be ...
Tuberose's user avatar
  • 444
2 votes
0 answers
681 views

Oracle SQL: failing to convert number to char

I have a table SOME_TABLE with a field SOME_NUMBER of type number. If I try to convert this field to char, I'm getting an error in some cases. This select select id, SOME_NUMBER, ...
Luigi Cortese's user avatar
2 votes
0 answers
46 views

Doing math in a PHP script from SQL DB

So I have a script the is measuring Fuel burned and lbs or loads and driven distance. So here is the script I have <td><?php ($row['trailerMass']); echo (($row['trailerMass']) * 2.2)."\n";...
Clumsy Zombie's user avatar
2 votes
0 answers
231 views

Can NSLog() format more than eight doubles in Swift?

When I try to format more than eight doubles in NSLog() in Swift, the first eight are fine. The remaining doubles often incorrectly come out as 0.0. Occasionally, instead of 0.0, I get a really long ...
bjc's user avatar
  • 1,231
2 votes
0 answers
2k views

PHP5.3 number_format returns NaN

I have this piece code developed in PHP5.5 without any issue. However, when same code is moved to another server in PHP5.3, the number_format() does not return expected value, but return "nan" This ...
shinega's user avatar
  • 123
2 votes
0 answers
559 views

Java or Android utils to shrink or format large number

Does android provide a way to shrink or abbreviate large numbers or do I have to roll out my own? For examples 1,000 => 1k 25,678 => 25.7k 3,456,245 => 3.5m Or at the very least, is there a built-in ...
learner's user avatar
  • 11.7k
2 votes
1 answer
163 views

Format Matlab data to only have digits after the decimal place

I used dlmwrite to output some data in the following form: -1.7693255974E+00,-9.7742420654E-04, 2.1528647648E-04,-1.4866241234E+00 What I really want is the following format: -.1769325597E+00, -....
user2232378's user avatar
2 votes
1 answer
355 views

setMaximumFractionDigits is not working for ThreadLocal<NumberFormat>

To make the NumberFormat operation threadsafe, I have used ThreadLocal as follows: public class ThreadSafeNumberFormatter { private static final ThreadLocal<NumberFormat> numberFormatHolder ...
Anushree Acharjee's user avatar
2 votes
0 answers
42 views

Tomcat shows different number formatting for GWT

I have following code to format float numbers NumberFormat nmf = NumberFormat.getFormat("#.00"); totalAmount=Float.parseFloat(nmf.format(totalAmount)); When I run my application in eclipse for ...
Akash Shinde's user avatar
2 votes
1 answer
1k views

NumberFormat without maximum fraction digits

Is there a way to create a NumberFormat instance with no maximum fraction digits? An obvious solution would be NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(...
shmosel's user avatar
  • 49.9k

1
2 3 4 5
12