number-formatting

Excel Range Format: Number is automatically formatted when Range::Value2 is set

自闭症网瘾萝莉.ら 提交于 2019-12-25 03:38:44
问题 I have an Excel addin written in C# that imports a text file into Excel worksheet. Some of the fields in the file are text and some oare numbers. Problem Steps: Change the System's Regional Settings to Dutch (Belgium) Open Excel and import the file into Excel. Records contain values such as 78,1118 which gets converted to 781.118. Note that in Dutch(Belgium), COMMA is the decimal character and DOT is the thousand character. I do not require the number to be formatted automatically but just

How to format this string

大兔子大兔子 提交于 2019-12-25 00:08:50
问题 I have an amount Long amount=83000; I need to format it to $83.000 , how to do this ? NumberFormat formatter = NumberFormat.getCurrencyInstance(new Locale("en", "US")); String moneyString = formatter.format(amount); System.out.println(moneyString); I am getting $83000.00 but i want my point before 3 last digit 回答1: This should work : DecimalFormatSymbols symbols = new DecimalFormatSymbols(new Locale("en", "US")); symbols.setDecimalSeparator(','); symbols.setGroupingSeparator('.');

How to define a formatted text field in Swing so that the format restrictions are applied as you type?

家住魔仙堡 提交于 2019-12-24 17:12:05
问题 I need such a numeric text field on JFrame that restricts the input by a number with two digits after decimal point lays out the number separating every three digits i.e. 1 234 567,89. the number is displayed in correct format right away during typing I tried using JFormattedTextField: NumberFormat nf = NumberFormat.getNumberInstance(); nf.setMaximumFractionDigits(2); NumberFormatter numFormater = new NumberFormatter(nf); field1 = new javax.swing.JFormattedTextField(numFormater); However,

Splitting amount using comma in oracle

佐手、 提交于 2019-12-24 15:27:53
问题 In oracle i need to split amount using comma such as 10,000 and 1,00,000 whatever it comes. I need to split this. Is there any solution available for this. Am stuck with this. my result set is comes as 1000 and 10000 etc.. 回答1: Use TO_CHAR and desired number format. SQL> with data(num) as( 2 select 100 from dual union 3 select 1000 from dual union 4 select 10000 from dual union 5 select 1000000 from dual 6 ) 7 SELECT TO_CHAR(num, '9,999,999') FROM data; Also, in SQL*Plus there is a default

C# String.Format() - number format doesn't work

≯℡__Kan透↙ 提交于 2019-12-24 11:28:30
问题 Having tried all different solutions from this question, it doesn't seem to give me the wanted format (1.000.000 | 1.234). I Have tried this: dataBlock.ValueCell.Value = String.Format("{0:#.##0}", double.Parse(dataBlock.ValueCell.Value)); // 1 234 dataBlock.ValueCell.Value = String.Format("{0:N0}", double.Parse(dataBlock.ValueCell.Value)); // 1 234 dataBlock.ValueCell.Value = String.Format("{0}", double.Parse(dataBlock.ValueCell.Value.ToString("N0"))); // 1 234 //values as I read them from

Matlab - short format of number variable in the plot title

萝らか妹 提交于 2019-12-24 01:56:10
问题 I am trying to place a variable into a plot title but I cannot produce formatting of 4 decimal places. How to avoid the float format in the title? This is the code I use subplot(3,2,1); hist(X,10); str=sprintf('X N=%d,Y=%d',N,Y) M=sum(X)/N Mean=sprintf('Mean=%0.4d',M) title({str,Mean}) 回答1: You need to use %f as the format specifier for float values. Changing your code Mean=sprintf('Mean=%0.4d',M) to Mean=sprintf('Mean=%0.4f',M) will print M with 4 decimal places of accuracy. If you want to

Excel's LEN() function returns 5 on numbers longer than 20 characters

╄→尐↘猪︶ㄣ 提交于 2019-12-24 00:37:12
问题 When I have numbers longer than 20 characters the LEN() function in excel returns 5. I've tried this on my desktop and my mobile and get the same result. When I use "Evaluate Formula" it shows it going from "LEN(100000000000000000000)"(20 zeros) to "5". In the case of 21 zeros it formats the number as scientific so it goes from "LEN(1E+21)" to "5". So I guess that at 21 characters excel stores numbers with the scientific notation and LEN() calculates the length of that. The anomaly of exactly

PHP how to convert number exponential number to string?

余生长醉 提交于 2019-12-23 17:18:35
问题 I have a number stored in scientific notation 2.01421700079E+14 I've tried using float, string, int and I can't get 0201421700079085 from 2.01421700079E+14 1. echo (float)$awb; 2. echo number_format($awb, 0, '', ''); 3. echo (int)$awb; 4. echo (string)$awb; 2.01421700079E+14 = float 201421700079085 = number 201421700079085 = int 2.01421700079E+14 = string 回答1: printf and friends will do this: <?php $awb = 2.01421700079E+14; $str = sprintf("%d", $awb); var_dump($str); Output: string(15)

How to format a Rational number as a decimal?

混江龙づ霸主 提交于 2019-12-23 17:16:26
问题 Given an arbitrary large (or small) Rational number that has a finite decimal representation, e.g.: r = Rational(1, 2**15) #=> (1/32768) How can I get its full decimal value as a string? The expected output for the above number is: "0.000030517578125" to_f apparently doesn't work: r.to_f #=> 3.0517578125e-05 And sprintf requires me to specify the number of digits: sprintf('%.30f', r) #=> "0.000030517578125000000000000000" 回答1: Most ten-year-olds know how to do that: use long division! 1 Code

f:convertNumber doesn't throw conversion error on trailing alphabetic characters in decimal

人走茶凉 提交于 2019-12-23 10:17:46
问题 I am using <f:convertNumber> tag to convert a decimal input. <f:convertNumber minFractionDigits="2" /> But it's accepting trailing alphabatic characters. For example, if I input 12345.1234AAA it converts to 12345.123 . I would like it to throw a conversion error on that instead of trimming the alphabetic characters. How can I achieve this? 回答1: This simply is the standard behavior of java.text.NumberFormat as used by <f:convertNumber> : It trims all entries after the first not-allowed