FAQ Database Discussion Community


Intl.NumberFormat#format maximum integer value

javascript,internationalization,number-formatting,ecmascript-intl
In ECMAScript Internationalization API 1.0 spec, NumberFormat object has a format function which takes in a value and formats the number according to NumberFormat object. What is the maximum value NumberFormat#format function can digest? In Chrome, and Firefox running below: new Intl.NumberFormat().format(1111111111111111); // => "1,111,111,111,111,110" // ^ // 16th digit...

Preserve number format when copying very many digits from a Text Box

excel,formatting,copy-paste,number-formatting
I have a long number in a Text Box: 032010203010301030103010300103010301032010101030103007 When I want to copy this number (Ctrl+c) into a cell, the number will be: 3.2010203010301E+52 I want the destination cell to have the original number format. What should I do?...

Kendo grid column number formatting

templates,kendo-ui,kendo-grid,number-formatting
How to set number formatting in kendo column if we bind 2 data values? In my example I have to bind value with unit, so I need a value written with 2 decimals. My code looks like: { field: "Quantity", title: "Value ", width: "70px", type: "number", format:"{0:n2}", template: "#:Quantity#...

Formatting float values in ios

ios,iphone,numbers,number-formatting
I have weight values, they can be like 75kg and 75.5kg. I want to have this values two styles: 75kg, 75.5kg, but NOT 75.0kg. How can I do it? I have this solution, but I not like it //show difference in 75 and 75.5 values style NSString *floatWeight = [NSString...

How to format a number value in AngularJS ui-grid cell to two decimal?

angularjs,angularjs-directive,number-formatting,angular-ui-grid
I'm using Angularjs ui-grid and using the default settings, the question is how can I format the numbers to two decimal? ...

ZF2 Form: NumberFormat-filter with localization

forms,filter,localization,zend-framework2,number-formatting
hy, how can I define the NumberFormat-filter for an input in a fieldset which is aware of the current locale? What I want is that numbers like 1000.33 are displayed in the view like this: 1.000,33 (or whatever locale is specified) I have tried it with the InputFilterProviderInterface, but it...

(VBA Excel) Extract Text and related Letter from String and output result

regex,string,excel-vba,character,number-formatting
So the scenario I have is there are letter with a number: Desired Output after Program (Note an underscore is visually used but I need a space: ____________F __G _____E __G__E______F Currently I have written code in the Number and First Letter Column to extract the number and first letter:...

Android - NumberFormatException Issue

android,android-fragments,number-formatting,numberformatexception
I'm having an issue with the following code when entering in a value with a decimal point. It doesn't matter if I enter in 56. or 56.3 or 56.345, it still makes the app crash and throws the NumberFormatException. Here is the code where the exception is being thrown: private...

Format currency to local locale, but ignore .00 decimal places

java,android,currency,number-formatting
I am trying to display a price for an item, in the relative currency given with the data, in the users locale format. e.g. The item is in EUR and in UK should be displayed as €123.64 but in France should be displayed as 123,64 € I want the currency...

Java Dealing with Double values having E [closed]

java,string,math,rounding,number-formatting
Suppose that I have: double Nc= 7.6695805E-4; NumberFormat formatter = new DecimalFormat("0.00000000000"); String string = formatter.format(Nc); System.out.println(string); the output would be: 0.00076695805 But it is place in string type variable! What i have to do is to convert it into double or float or long so that it should remain...

Format number different depending on mobile or business phone

php,mysql,if-statement,number-formatting
Currently in my php application I have the following code that formats the unformatted 10 digit australian phone number to XX XXXX XXXX. What I would like to do is if the phone number in the database starts with 04 then it will format it as 4,3,3 like XXXX XXX...

How to make any double datatype into 0.00 (2 digits after decimal point) format taking in another double datatype (Android/Java)? [duplicate]

java,android,number-formatting
This question already has an answer here: How to round a number to n decimal places in Java 16 answers I'm beginner in android developing. How can I make a double datatype i.e 56.32534 into 56.33? But I want to take it in a double variable. I know a...

how to get the three decimal point of a no in javascript [closed]

javascript,decimal,number-formatting
So , i have a problem . i am calculating the discount and it may be in decimal points . the method i am using is not working for the value 0.0038575 and the method is value=0.0038575 Math.round(value * 100) / 100, it is returning the same value . this...

How to set a double format by locale

java,locale,number-formatting,decimalformat
I those input strings: 10000,20 4000,10 5,400.20 I am trying to format them with locale: nf = NumberFormat.getInstance(Locale.FRANCE); double newLoc = nf.parse(split[5]).doubleValue(); And also like this: nf = NumberFormat.getInstance(Locale.ENGLISH); double newLoc = nf.parse(split[5]).doubleValue(); Result is: for Locale.FRANCE 5400.2 4000.0 10000.0 For Locale.ENGLISH 4000.0 10000.0 5400.0 But what in need is...

Replace point with comma in a JTable causes a wrong sorting-sequence

java,swing,sorting,jtable,number-formatting
I've tried many things to display a comma instead of a point in my JTable in "German"-style. In my JTable-Class I wrote a methode for looping a passed ResultSet for filling a DefaultTableModel and returning the Model or the JTable directly. If I cast a BigDecimal to a String for...

Oracle - Format number with fullstop for thousand and comma for decimals

sql,oracle,number-formatting
I've a number like this 3225,69 and I want to convert the display to: 3.225,69 Simply, I need full stop to separate thousand and comma to separate decimals: 3,69 -> 3,69 1000 -> 1.000 1500,20 -> 1.500,20 1 -> 1 (not 1,000) Which mask should I use in to_char? I'm...

NumberFormatException while converting a *binary* string to a number

java,binary,integer,number-formatting
So I have this binary string (32 chars corresponding to 32 bits): String s = "11111111110000011101110111011000"; When I try to convert it to a number, it throws a NumberFormatException: Integer.parseInt(s,2); Could not figure out why. Any idea? The strange thing is if I replace the first bit in the string...

PHP formatting of positive and negative floating point numbers with leading zeros

php,floating-point,printf,number-formatting,negative-number
Scenario: To trim leading zeros from positive and negative floating point numbers Input: 000.123 00.123 01.123 -001.123 -00.123 -040.123 Desired output: 0.123 0.123 1.123 -1.123 -0.123 -40.123 Question: Is there an inbuilt function which will make this specific formatting easier and more efficient than running each number through combinations of...

C# string to number, TryParse returns true when Parse fails

c#,linq,linq-to-sql,number-formatting,tryparse
I have a column in my database (SQL Server) storing averages as varchar. Values are not always valid numbers, it can be something like : 0, 12, 5.5, .4, 4.0, 6., 5.21428571428571428571428571428571428571, X, fail, or simply empty text. When assigning variable with linq, I want to display : success if...

PHP Round With Decimal & Comma $1,000

php,rounding,number-formatting
<?= round(number_format($vehicle->prices['total_rental'], 2, '.', ',') * 0.50,2) ?> I would like the output to round up to the next 2 decimal places (for money / dollars & cents). This works great when $vehicle->prices is below $1,000. When $vehicle->prices is above $1,000, it just outputs .50. What is the correct way...

how do i properly make a for loop sit on one line, with commas and no spaces

python,loops,python-3.x,for-loop,number-formatting
I'm new to coding and it's a little frustrating at the moment because i have to do an assessment where it outputs "1,2,fizz,4,buzz,fizz,7,8,fizz,buzz,11,fizz,13,14,fizzbuzz,16,17,fizz,19,buzz" and no i cant use print. Code: import sys num1=int(input('Enter your number range: ')) for x in range(1,num1+1): if x % 3 == 0: print("Fizz",end=" ") if...

When should I var_export(…, TRUE), when FALSE?

php,numbers,export,number-formatting
I have an array that I want to write to a file. This file will be included in another script and the array read and processed. The array contains floating point numbers rounded to two decimals using number_format(round($number, 2), 2, '.', '') (to preserve zeros): print_r($array,true); Array ( [0] =>...

Adding # Format to Values

excel,vba,excel-vba,number-formatting
I have a simple form where I have a user inputting certain data. With that data, I need some values calculated and I also need the values to come up as either currency or percentage. The code is: Private Sub cmdAdd_Click() Dim emptyRow As Long Dim ctl As Control Dim...

What is the correct format to use in PHP when denoting “money” attribute fetched from MySQL database?

php,mysql,number-formatting,money-format
I'm using the "number_format" function to denote money" attribute in PHP/MySQL. The attribute itself is stored in my database. Select account_balance from my_table where login = 'xxxxxx'; $correct_account_balance = number_format($account_balance, ['my_balance'],2); } In other words : the denotation "2" will add two extra numbers after the decimal point, as follows...

How to format the input of EditText when typing with thousands separators (,) in Android?

java,android,android-edittext,number-formatting,textwatcher
I've an edittext , it only gets numeric without decimal numbers. android:inputType="number" I want to separate thousands while I'm typing . For example 25,000 . I know I should use TextWatcher and I've used this code but I couldn't make it work : @Override public void afterTextChanged(Editable viewss) { String...

NumberFormat for report formatting

java,number-formatting
I'm trying to do a quick report in Java and I'm having issues formatting the numbers. Here's what I have now: MessageFormat lineFormat = new MessageFormat("{0}\t{1,number,#,##0}\t {2,number,#0}\t\t {3,number,#0.00}"); The problem is that array index 1 (and 3 some) is sometimes hundreds and sometimes thousands and that this setting eliminates the...

formatting time (using timespec) to get the right value in nano seconds

c++,time,number-formatting
I wish to format ns and ns_old, so that I verify if obeys the inter_arrival that is set (ie, if i give inter_arrival =10, it should rightly reflect in ns_diff). Could someone give some details on how to do this. #include <iostream> #include <stdlib.h> #include <ctime> // for getting time...

format phone number using angularJs

javascript,angularjs,number-formatting,phone-number,angular-filters
How would I format a number like: (99) 9999-9999 into: 9999999999 using angularjs? someone told me to use phoneformat.js but I don't know how to implement it in my project

Counting Change with decimal point (probably simple solution)

java,number-formatting
I have the following code (I'm not very computer literate so be gentle) that the user is supposed to be able to enter individual coin amounts and the program will tell the user how much money they have in said coin amounts. import java.util.*; public class Coins { public static...

Formatting Integers in JTable Column Cells With Commas

java,swing,jtable,format,number-formatting
I have a Price column that displays integers in plain format like 1000000. I would like to know how can I format it with commas without affecting its value when retrieving with table.getValueAt()? Is there a method like table.setColumnCellFormat(decimalFormat)?...

FusionChart Multi-series dataset number prefix

dataset,number-formatting,fusioncharts
Is it possible to each dataset to have it's own numberPrefix? <graph caption='Product Sales' numberPrefix='$' > However this puts the same dollar sign for every dataset. What i want is to show for product A , totals in EUR / GBP / USD, and for product B EUR / GBP...

Send E-mail through outlook via Excel VBA - convert string to currency format or percent

email,excel-vba,number-formatting
New to the site and very new to programming/VBA. I work for a sales company, and I would like to send a basic email to each of our reps letting them know their monthly sales v goal and the percent of Goal Here is my (very basic) code I need...

find all numbers in a string with a NSScanner

objective-c,string,number-formatting,nsnumber,nsscanner
I used the below code to extract numbers from inputString using NSScanner NSString *inputString = @"Dhoni7 notout at183*runs in 145andhehit15four's and10sixers100"; NSString *numberString; NSArray *elements = [inputString componentsSeparatedByString:@" "]; for (int i=0; i<[elements count];i++) { NSScanner *scanner = [NSScanner scannerWithString:[elements objectAtIndex:i]]; NSCharacterSet *numbers = [NSCharacterSet characterSetWithCharactersInString:@"1234567890"]; // Throw away characters...

RoundingMode.UNNECESSARY throws exception

java,exception,number-formatting,bigdecimal
I wrote this to test BigDecimal in action but found that RoundingMode.UNNECESSARY threw an exception. Can anyone explain why? public class TestRounding2 { public static void main(String args[]) { Locale swedish = new Locale("sv", "SE"); BigDecimal pp; //declare variable pp=pounds pence NumberFormat swedishFormat = NumberFormat.getCurrencyInstance(swedish); Scanner scan = new Scanner(System.in);...

How to find string value is in exponential format in C#?

c#,wpf,string,number-formatting,exponential
I want to find whether string has exponential format or not. Currently i am checking like below. var s = "1.23E+04"; var hasExponential = s.Contains("E"); But i know this is not the proper way. So can anyone please guide proper and fastest way to achieve my requirement?...