number-formatting

Format input as number with locale in Angular 6

夙愿已清 提交于 2019-12-08 08:14:40
问题 I am trying to format a number in a text input in the locale of the user. I tried to use DecimalPipe and a custom self-made pipe and both work at first. The problem is, as soon as the number is formated into a string, the pipe doesn't work anymore since it is supposed to be applied on a number. So for example when I type 1234.23 , it displays 1 234,23 but the DecimalPipe doesn't work on 1 234,23 and I get the NaN error. I didn't find anything that allows me to turn back the formatted text

Locale for Norwegian, Bokmal(Norway) issue

感情迁移 提交于 2019-12-08 07:48:48
问题 I am facing problem while opening a downloaded CSV file in Excel under window 7 for above locale. Sometime the number is treated as date and all the cells are misaligned and formatted incorrectly. I have written code for CSV download with the localized format. It's working perfectly for all the regions except this one. I invested the issue and it came to know that there is a mismatch between format defined on Windows 7 system and locale retrieved from ServletRequest#getLocale() for Norwegian,

Number formatting in Oracle using TO_CHAR

核能气质少年 提交于 2019-12-08 02:56:13
问题 Proper way to format the numbers in ORACLE stored procedures. I need to display currency fields with 2 decimals. Expected output is as follows: 0 > 0.00 5 > 5.00 1253.6 > 1253.60 1253.689 > 1253.69 Below worked for me: select to_char(9876.23 , 'fm999990.00') from dual; But this has the issue of hard coding a bunch of 9s. If I give a larger number it will be displayed as "##############" Is there any other way I can do this? 回答1: I need to display currency fields with 2 decimals. Ensure you

How to make Excel doesn't truncate 0's in formatting decimal numbers?

折月煮酒 提交于 2019-12-08 01:57:31
问题 Suppose that I have the following random numbers in Notepad: 1.19 0.040 10.1123 23.110 21.223 2.35456 4.0 10234.0009 456798.7500 123 34.560 40060 33.7876 If I copy the numbers above and paste them in Excel, the number formats will change to this 1.19 0.04 10.1123 23.11 21.223 2.35456 4 10234.0009 456798.75 123 34.56 40060 33.7876 I intend to copy-paste the numbers without changing their original formats, for examples: 0.040 keeps 0.040, not 0.04; 4.0 keeps 4.0, not 4; 456798.7500 keeps 456798

Convert number into culture specific

房东的猫 提交于 2019-12-07 22:31:29
I have a number like 202667.4 . I want to convert this to number based on culture . For Ex: In "de"(German) the number should be in 202.667,40 . Any help will be greatly appreciated. Thanks. If you want to represent existing number (say, double ) in culture specific format, try formatting : https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings double source = 202667.4; // "n" - ... group separators, and a decimal separator with optional negative sign // "de" - German culture string result = source.ToString("n", CultureInfo.GetCultureInfo("de")); Console

Excel Custom Decimal Number Format Trailing Dot [closed]

北城以北 提交于 2019-12-07 16:25:20
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . When I set custom number format #0.#### , it works fine with whole numbers 123 & 123.23 , but it is not working with decimal numbers like 123.00 , as it is displaying this as 123. How can one set a correct number format so as not to display the . at the end? 回答1: You can use conditional formatting to do this, in

NumberFormatException on European Versions of Android?

删除回忆录丶 提交于 2019-12-07 11:58:44
问题 I have an app which runs the following two lines of code upon starting: DecimalFormat decim = new DecimalFormat("#.00"); return Double.parseDouble(decim.format(totalNumberOfCredits)); When I start the app on my American phone, the value of decim.format(totalNumberOfCredits) is .00 . However, in my Google Play Developer Console, I have a dozen crashes, all of which look like this: Caused by: java.lang.NumberFormatException: Invalid double: ",00" at java.lang.StringToReal.invalidReal

Boost's lexical_cast From double to string Precision

痞子三分冷 提交于 2019-12-07 10:29:42
问题 I'm working with a library that unfortunately uses boost::lexical_cast to convert from a double to a string . I need to be able to definitively mirror that behavior on my side, but I was hopping to do so without propagating boost . Could I be guaranteed identical behavior using to_string , sprintf , or some other function contained within the standard? 回答1: The boost code ends up here: bool shl_real_type(double val, char* begin) { using namespace std; finish = start + #if defined(_MSC_VER) &&

How to print formatted float in obj-c?

谁说我不能喝 提交于 2019-12-07 06:45:05
问题 How to print a float in Objective-C as, for example, 3.45 instead of 3.45555555555 ? 回答1: Try formatting the float like this: NSLog(@"%.2f", myFloat); The % sign means this will be replaced by the corresponding argument following ( myFloat ). The .2 means 2 decimal places, and f means a float datatype. Take a look here for more detail. Objective-C's NSLog is very similar to C's printf , with the main exceptions being that you must use an Objective-C string literal ( @"…" ) and you should use

Is there a way to get the decimal and thousands separator in ECMAscript Internationalization API?

痞子三分冷 提交于 2019-12-07 06:04:47
问题 I'm trying to use the new Javascript internationalization API, and would like to know if there is a way to get the decimal and thousands (grouping) separator for a Intl.NumberFormat instance? There is a resolvedOptions method on the object, but that does not provide the symbols. In case anybody's wondering, then for en-US, these would be a comma , and period . , such as in 1,000.00 . 回答1: I'm afraid ECMA-402 standard does not define the API that let you access separators. There is also