number-formatting

Arbitrary Currency String - Get all parts separated?

大城市里の小女人 提交于 2019-12-06 07:43:35
问题 I have arbitrary String with currencies like 100,00€ or $100.00 or 100.00USD (arbitrary lenght, any valid Currency on earth both Symbol and ISO-Code )...(=like 100.000.000,00 EUR ). There is no guarantee that the currencies are correct, it might be an invalid Symbol or Character or at the wrong position (after or before the number)... What is the easiest way to get: The integer part The decimal part The Currency (if valid) I know of NumberFormat/CurrencyFormat but this class is only usefull

Detect culture of number in VB.Net i.e. period or comma for decimal point / thousands separator

狂风中的少年 提交于 2019-12-06 06:30:34
In VB.Net, is there a way of auto-detecting the culture of a string representation of a number? I'll explain the situation: Our asp.net web site receives xml data feeds for boat data. Most of the time, the number format for the prices use either a simple non-formatted integer e.g. "999000". That's easy for us to process. Occaisionally, there are commas for thousands separators and periods for the decimal point. Also, that's fine as our data import understands this. Example "999,000.00". We're starting to get some data from France where some of the prices have been entered with the periods and

Converting a decimal to a hexadecimal number

家住魔仙堡 提交于 2019-12-06 04:06:19
问题 Why we use + 55 for converting decimal to hex num . in this code we use +48 to convert integer to character . when temp < 10 . But when temp > =10 we use +55 . what does it mean by +55 ? #include<stdio.h> int main(){ long int decimalNumber,remainder,quotient; int i=1,j,temp; char hexadecimalNumber[100]; printf("Enter any decimal number: "); scanf("%ld",&decimalNumber); quotient = decimalNumber; while(quotient!=0){ temp = quotient % 16; //To convert integer into character if( temp < 10) temp

Mathematica internal number formats and precision

主宰稳场 提交于 2019-12-06 03:33:40
问题 Tangentially related to this question, what exactly is happening here with the number formatting? In[1] := InputForm @ 3.12987*10^-270 Out[1] := 3.12987`*^-270 In[2] := InputForm @ 3.12987*10^-271 Out[2] := 3.1298700000000003`*^-271 If you use *10.^ as the multiplier the transition is where you would naively expect it to be: In[3] := InputForm @ 3.12987*10.^-16 Out[3] := 3.12987`*^-16 In[4] := InputForm @ 3.12987*10.^-17 Out[4] := 3.1298700000000004`*^-17 whereas *^ takes the transition a bit

Numbers in the form of 001

南笙酒味 提交于 2019-12-06 03:33:30
问题 Is there a special name for numbers in the format of 001. For example the number 20 would be 020 and 1 would be 001. Its hard to Google around when you don`t know somethings name! Since I am already wasting your guys time does any one know a function for changing numbers to this format. 回答1: I think this is usually called "padding" the number. 回答2: Its called left zero padded numbers. 回答3: It's called padding. 回答4: Well, if you're talking about that notation within the context of certain

LISP - digits after decimal point

為{幸葍}努か 提交于 2019-12-06 02:06:33
问题 does anyone know how to specify the numer of digits after the decimal point for a float in Lisp? Say if I print this command at the REPL: CL-USER 3 > (format t "~,15f" (float (/ 1 7))) I get: 0.142857150000000 But the number is rounded at the 8th digit after the decimal point, I need to see a lot of digits after the decimal point in order to see if the number is cyclic and to calculate the period. (Actually I'm starting to try and solve Project Euler's problem 26). I need to get something

Format double values using a maximum of five total digits, rounding decimal digits if necessary

笑着哭i 提交于 2019-12-06 01:37:21
问题 I have double values which I would like to convert to String values with the following format restrictions: number_of_fraction_digits = max( 0, 5 - number_of_integer_digits ) Essentially I want to keep the number of digits to 5 if possible, rounding decimal digits if necessary. For example: float String ------------------------- 1 1 100 100 100000 100000 99999 99999 99999.99 99999 9999.99 9999.9 999.99 999.99 23.34324 23.343 I've looked into using DecimalFormat but as far as I can tell it

Formatting phone number to E164 format in Android

坚强是说给别人听的谎言 提交于 2019-12-05 22:41:19
问题 I want convert every phone number from conatct in device to E164 format. So, I used opensource below. libphonenumber So I used it like here. Phonenumber.PhoneNumber formattedNumber = null; String formatted = null; try { formattedNumber = phoneUtil.parse(phoneNumber, "KR"); formatted = phoneUtil.format(formattedNumber,PhoneNumberUtil.PhoneNumberFormat.E164); if (StringUtils.isEmpty(formatted) == false && formatted.length() > 0 && StringUtils.isEmpty(name) == false && name.length() > 0) {

NumberFormatException on European Versions of Android?

家住魔仙堡 提交于 2019-12-05 22:39:24
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(StringToReal.java:63) at java.lang.StringToReal.parseDouble(StringToReal.java:269) at java.lang.Double

How can I round to a certain floating-point precision?

不想你离开。 提交于 2019-12-05 22:28:37
I think it's a simple question. I want: a = 1.154648126486416; to become: a = 1.154; and not: a = 1.15000000000; How do I do that without using format('bank') . You could do this: a = floor(a*1000)/1000; Building on @gnovice's answer, you can format the output as a string to get rid of the extra zeros. See the sprintf documentation for all the formatting options. str=sprintf('The result is %1.3f.',a); disp(str) will show "The result is 1.154." in the command prompt. Or write the string to file, etc., etc. a = 1.154648126486416; % desired precision b = -3; % your answer ans = floor(a*10^(-b))/