number-formatting

NumberFormat.parse() does not work for FRANCE Locale space as thousand seperator

本秂侑毒 提交于 2019-12-11 13:42:56
问题 I have written below Java code to see how locales behave with numbers. I am facing with FRENCH style. double n = 123456789.123; System.out.println("US "+ NumberFormat.getNumberInstance(Locale.US).format(n)); //###,###.### System.out.println("FRENCH "+ NumberFormat.getNumberInstance(Locale.FRENCH).format(n)); // # ###,## System.out.println("GERMAN "+ NumberFormat.getNumberInstance(Locale.GERMAN).format(n)); // ###.###,## System.out.println(NumberFormat.getNumberInstance(Locale.US).parse("123

Series of if statements applied to data frame

♀尐吖头ヾ 提交于 2019-12-11 13:26:22
问题 I have a question on how to this task. I want to return or group a series of numbers in my data frame, the numbers are from the column 'PD' which ranges from .001 to 1. What I want to do is to group those that are .91>'PD'>.9 to .91 (or return a value of .91), .92>'PD'>=.91 to .92, ..., 1>='PD' >=.99 to 1. onto a column named 'Grouping'. What I have been doing is manually doing each if statement then merging it with the base data frame. Can anyone please help me with a more efficient way of

custom number formatting in rdlc report

ⅰ亾dé卋堺 提交于 2019-12-11 10:42:53
问题 Is there a way in rdlc reports to format numbers as such:- add thousand separators but leave decimal places as is, so 1000.00 --> 1,000.00 1000 --> 1,000 回答1: Absolutely, in TextBox properties window select Number tab, select "Number" category and choose how you want to format your number: 来源: https://stackoverflow.com/questions/36238823/custom-number-formatting-in-rdlc-report

Exponential number in custom number format of Excel

不羁岁月 提交于 2019-12-11 10:25:33
问题 In an Excel chart, I have some values on the x-axis: 1, 2, 3, 4, 5 But these values are actually in logarithm. Therefore, I need to show the exponential numbers as the labels of x-axis like: 10, 100, 1000, 10000, and 100000. I tried the 'Format Axis' --> 'Number' --> 'Custom' in order to add a new format code to support that. But it didn't work. The best thing I've got so far is 10^#,##0;10^#,##0 But it just gives me exactly 10^x which is not what I need. Any idea? 来源: https://stackoverflow

How to make strings from floating-point numbers with '.' (dot) as a decimal separator and not more than 3 digits after floating point?

寵の児 提交于 2019-12-11 10:07:10
问题 I have this code: public String formatDouble(double d) { return String.format("???", d); //Should I use NumberFormat here? } For the sample input: 1.00 1,00 1,23 1.234567 I would like to get this output: 1 1 1.23 1.234 How can I configure the pattern (or maybe NumberFormat instance) for producing the correct output? 回答1: This would do roughly what you need: Decimalformat df = new DecimalFormat("0.###"); df.setRoundingMode(RoundingMode.FLOOR); df.format(1.2345); However, the decimal separator

Are there cultures in which the decimal separator is longer than one character?

邮差的信 提交于 2019-12-11 07:55:23
问题 I must write a stringToNumber parsing function that can use custom strings for the following: decimal separator ( . for en-US => 3.1415 ) thousands separator ( , for en-US => 1,000,000 ) positive sign ( + for en-US => +5 ) negative sign ( - for en-US => -5 ) Can I assume that these are only one character (which would make the implementation easier) or are there any cultures in which any of these are longer? 来源: https://stackoverflow.com/questions/46538917/are-there-cultures-in-which-the

Comma Separate Number Without stringstream

时光总嘲笑我的痴心妄想 提交于 2019-12-11 07:33:15
问题 So typically if I wanted to insert locale appropriate separators in some number, foo , I'd do something like this: ostringstream out; out.imbue(locale("en-US")); out << foo; Then I could just use out.str() as the separated string: http://coliru.stacked-crooked.com/a/054e927de25b5ad0 Unfortunately I've been asked not to use stringstreams in my current project. Is there any other way I can accomplish this? Ideally a locale dependent way? 回答1: So this answer is the C++ distillation of Jerry

Accepting international numbers with decimal and thousands separator in PHP

风流意气都作罢 提交于 2019-12-11 03:29:18
问题 For an online calculator where users may enter an energy amount to calculate corresponding fees, I need the PHP script to accept various user inputs. The value of "2 million and one fourth joule" may be entered as: 2000000.25 (default notation) 2,000,000.25 (with thousands separator) 2000000,25 (comma as decimal point) 2.000.000,25 (comma as decimal point, with thousands separator) 2'000'000.25 (alternative format) 2 000 000,25 (French notation) How could I make the script aware of such

Intl.NumberFormat() does not show the Bitcoin Ƀ Symbol

冷暖自知 提交于 2019-12-11 01:14:52
问题 the Intl.NumberFormat does not show the bitcoin symbol. CFORMAT_USD = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'USD', minimumFractionDigits: 8 }); CFORMAT_BTC = new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'BTC', minimumFractionDigits: 8 }); console.log(CFORMAT_USD.format(1000)); // 1.000,00000000 $ console.log(CFORMAT_BTC.format(1000)); // 1.000,00000000 BTC My workaround at the moment console.log(CFORMAT_BTC.format(1000).replace(/BTC/,'Ƀ')); // 1.000

Fixed digits number in floats

本小妞迷上赌 提交于 2019-12-11 01:09:38
问题 I read a lot of discussion about this on SE, but still can't find the right one. I want to plot some numbers, of various lengths, with the same number of digits. For example I have: 12.345678 , 1.2345678 . Now, since I have to plot them with their error, I want that each one has a different format, in order that they are significant. So, I want to plot them with a variable number of decimals. In my case, it makes no sense to plot 23.45678+/-1.23456 but better is 23.4+/-1.2 . On the other hand