number-formatting

Large numbers to string in JavaScript

拟墨画扇 提交于 2019-12-01 16:47:07
When I do the following: alert((2053716830872415770228778006271971120334843128349550587141047275840274143041).toString()); I get the "2.053716830872415e+75" exponential notation. I want to alert the number as is. I tried toFixed(), toPrecision() and toLocaleString() and they output the same thing. How can I accomplish this? Note: the number is a variable, so I cannot alert("208.."); Javascript uses 64-bit floating point numbers . It is impossible to precisely store your value in a Javascript number. Instead, you should use a BigInteger library. http://www.leemon.com/crypto/BigInt.html http:/

Large numbers to string in JavaScript

此生再无相见时 提交于 2019-12-01 16:43:28
问题 When I do the following: alert((2053716830872415770228778006271971120334843128349550587141047275840274143041).toString()); I get the "2.053716830872415e+75" exponential notation. I want to alert the number as is. I tried toFixed(), toPrecision() and toLocaleString() and they output the same thing. How can I accomplish this? Note: the number is a variable, so I cannot alert("208.."); 回答1: Javascript uses 64-bit floating point numbers. It is impossible to precisely store your value in a

NumberFormat parse not strict enough

时光总嘲笑我的痴心妄想 提交于 2019-12-01 16:10:48
I have a JFormattedTextField with a NumberFormat with Locale.US. So the decimal separator is the point and the grouping separator is the comma. Now I type the string "1,23" in this text field and move the focus to another component. I would expect the string to disappear (like it does when i type "a" instead of "1,23") because it is obviously not a valid representation of a number when using Locale.US. But instead the text in the text field is changed to "123". This is because the used NumberFormat is not strict when parsing and simply ignores the comma. Question : How can I tell NumberFormat

CSS Kerning for Large Numbers

半城伤御伤魂 提交于 2019-12-01 16:09:28
I realise that in the states large numbers are formatted with a , between thousands so you would write $1,000,000.00 . In South Africa a , is non-standard and could be used as a decimal point instead of the . . We would write $1000000.00 which is horrible to read. The typical solution is to use a bit of whitespace: $1 000 000.00 . The problem with that solution is that it still looks terrible. If I assume values are currency formatted in a particular DOM element (i.e. the numbers are suffixed with .00 even if it's double zero), the ideal solution would be to use CSS to somehow manipulate the

Format Y axis values, original figures in millions, only want to show first three digits

こ雲淡風輕ζ 提交于 2019-12-01 15:51:10
Data for my Y axis (each country) has figures in millions: { date: "1960", germany: "72542990", spain: "30327000", france: "46621166", italy: "50025500" } How do I write the .tickFormat(d3.format("")); on my Y axis variable to format the tick values so they show up in the Y axis scale like this: 0, 20 million, 40 million, 60 million, 80 million Currently they show up as 0, 20000000, 40000000, 60000000,80000000 Thanks. Declare Formatter formatValue = d3.format(".2s"); Use inside TickFormat .tickFormat(function(d) { return formatValue(d)}); to replace M with million try this.. .tickFormat

Why did MATLAB delete my decimals?

允我心安 提交于 2019-12-01 15:25:10
问题 Let's say I create some number A , of the order 10^4 : A = 81472.368639; disp(A) 8.1472e+04 That wasn't what I wanted. Where are my decimals? There should be six decimals more. Checking the variable editor shows me this: Again, I lost my decimals. How do I keep these for further calculations? 回答1: Scientific notation, or why you didn't lose any decimals You didn't lose any decimals, this is just MATLAB's way of displaying large numbers. MATLAB rounds the display of numbers, both in the

CSS Kerning for Large Numbers

我只是一个虾纸丫 提交于 2019-12-01 15:08:23
问题 I realise that in the states large numbers are formatted with a , between thousands so you would write $1,000,000.00 . In South Africa a , is non-standard and could be used as a decimal point instead of the . . We would write $1000000.00 which is horrible to read. The typical solution is to use a bit of whitespace: $1 000 000.00 . The problem with that solution is that it still looks terrible. If I assume values are currency formatted in a particular DOM element (i.e. the numbers are suffixed

Printing integers with thousands separators in Windows using C

蓝咒 提交于 2019-12-01 13:45:58
The question is pretty self-explanatory, I suppose. I am using printf and friends (snprintf etc) to display some memory statistics that are in the millions or hundreds-of-thousands range. Reading a number formatted like "1,523,556" is much easier than "1523556" to my lazy way of thinking. I have tried setting the locale and using the apostrophe flag before the format specifier (%'d and %'llu), but the apostrophe is apparently a standard from the SUS, so it may not work for me under Windows anyway. Is there a Windows-specific API for doing this? I am working with Pelles C and programming in

Truncate extra zeroes when formatting a float into an NSString

[亡魂溺海] 提交于 2019-12-01 11:21:55
问题 I am trying to format some float s as follows: 1.1500 would be displayed as “$ 1.15” 1.1000 would be displayed as “$ 1.10” 1.0000 would be displayed as “$ 1.00” 1.4710 would be displayed as “$ 1.471” 1.4711 would be displayed as “$ 1.4711” I tried with NSString *answer = [NSString stringWithFormat:@"$ %.2f",myvalue]; 回答1: I have figure out this. you can do this as per below implementation. Please take a look at below demo code... NSArray * numbers = [[NSArray alloc] initWithObjects:@"1.1500",

Printing integers with thousands separators in Windows using C

时光总嘲笑我的痴心妄想 提交于 2019-12-01 09:50:32
问题 The question is pretty self-explanatory, I suppose. I am using printf and friends (snprintf etc) to display some memory statistics that are in the millions or hundreds-of-thousands range. Reading a number formatted like "1,523,556" is much easier than "1523556" to my lazy way of thinking. I have tried setting the locale and using the apostrophe flag before the format specifier (%'d and %'llu), but the apostrophe is apparently a standard from the SUS, so it may not work for me under Windows