number-formatting

Java NumberFormat with equivalent negative and positive pattern

杀马特。学长 韩版系。学妹 提交于 2019-12-13 04:55:21
问题 I want to format a number without any prefix (or the same prefix) for both positive and negative numbers. The specification of NumberFormat states that you can specify a sub pattern for positive numbers and a sub pattern for negative numbers, separated by a semicolon. Each subpattern has a prefix, numeric part, and suffix. The negative subpattern is optional; if absent, then the positive subpattern prefixed with the localized minus sign ('-' in most locales) is used as the negative subpattern

Currency to words mispelling problems

和自甴很熟 提交于 2019-12-13 04:15:17
问题 This is the code below for converting numbers to words. What is the exactly problem ? Everything is great in English but in my country (Romania) there is different spelling let's make that clear in a few examples : Ex. 1 - English, One dollar,One thousand, One hundred, Two hundred that's how you write Romanian, Un dollar, O mie, O suta, Doua Sute, Trei Sute, there is a plural changing on the words, In English you use One for everything almost in Romanian this changes and I don't know how to

Oracle To_Char function V in format string

馋奶兔 提交于 2019-12-13 03:34:20
问题 I was given Oracle code and I'm trying to figure out what it is doing. Specifically it's converting a number to a string and I don't understand it. The code is: TO_CHAR(QTY_DISPENSED,'0000000V000') What does the V do? Jeff 回答1: It's a "Format Model" for converting numbers to strings: https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm Returns a value multiplied by 10n (and if necessary, round it up), where n is the number of 9's after the V. So basically it's taking

Create function normal number formatting?

蹲街弑〆低调 提交于 2019-12-13 02:12:06
问题 I tried the following code but is doesn't work triggers an error: val.reverse is not a function How can I fix it? Demo: http://jsfiddle.net/9ysZa/ //I want this output: 1,455,000 function num(val){ var result = val.reverse().join("") .match(/[0-9]{1,3}/g).join(",") .match(/./g).reverse().join(""); return result } alert(num('1455000')) 回答1: DEMO reverse is a method on Array.prototype —it works with arrays. Since val is a string, you'll need to call val.split('') to get it into an array.

A question about NumberFormatter

限于喜欢 提交于 2019-12-12 19:17:11
问题 Here is the code, I am hoping that this will add the constraint that only integer input is valid for the text field: JFormattedTextField ftf = new JFormattedTextField (); NumberFormat format = NumberFormat.getNumberInstance(); format.setParseIntegerOnly(true); ftf.setFormatterFactory(new DefaultFormatterFactory(new NumberFormatter(format), new NumberFormatter(format), new NumberFormatter(format))); But what suprised me is that when I input 100aaa, it is valid, 100.111, it is valid too. how

Adding digit spacing with jQuery

落爺英雄遲暮 提交于 2019-12-12 18:24:37
问题 I would like to inspect a span element and check for its number format and apply digit grouping to it with jquery It the number has more than 3 digits, that is for >1000, it must do digit grouping, to separate the thousands from the hundreds, and the hundred thousands from the thousands: eg. <span>5500000.00</span> should become <span>5 500 000.00</span> Is that possible with jQuery? 回答1: There are number of formatting plugins for this task. Or use can use regular expression. function

How can I format a formulaic result in C# Excel Interop?

让人想犯罪 __ 提交于 2019-12-12 13:26:30
问题 I've got this code that sums the values in the given range (Column O Row 10 to Column O the last signficant row): Note: That's the letter "O" not the number "Zero". var totalTotalPackageCountCell = (Range)_xlSheetDelPerf.Cells[curDelPerfRow + 2, TOTAL_PACKAGE_COUNT_COLUMN]; totalTotalPackageCountCell.Formula = string.Format("=SUM(O10:O{0})", curDelPerfRow); It works pretty dandy except for one thing: the value displays without commas, such as "20192" (I want it to be "20,192"). I tried this:

How to create a NumberFormat in Java that supports both an upper-case and a lower-case E as an Exponent Separator?

六眼飞鱼酱① 提交于 2019-12-12 12:16:51
问题 I have the following code: NumberFormat numberInstance = NumberFormat.getNumberInstance(); System.out.println(numberInstance.parse("6.543E-4")); System.out.println(numberInstance.parse("6.543e-4")); which produces the following output: 6.543E-4 6.543 Is there a way to tweak a NumberFormat to recognize both an upper- and lower-case E as the exponent separator? Is there a best work-around? Anything better than running toUpper() on the input first? 回答1: The answer is "no", not directly. Although

Use scientific notation only if needed

狂风中的少年 提交于 2019-12-12 11:11:08
问题 I want to parse a double value into a string . I want my number to have a specified number of digits (that I won't know until runtime). If this number can be expressed with a non-zero value in number of digits this is what I want. If the number comes out as zero's like this I want it expressed in scientific notation. Some examples will make this more clear, this assumes I wanted 3 digits: Value: .2367 Output: "0.23" Value: .00367 Output: "3.67E-3" Value: 22.3 Output: "22.3" Value: 3364.0

Parsing number with negative suffix

巧了我就是萌 提交于 2019-12-12 10:45:23
问题 Can someone explain to me why the below code gives this output? 1.2 null Running the following code: String positive = "1.2+"; String negative = "1.2-"; DecimalFormat format = new DecimalFormat("0.0"); format.setPositiveSuffix("+"); format.setNegativeSuffix("-"); format.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.US)); System.out.println(format.parse(positive, new ParsePosition(0))); System.out.println(format.parse(negative, new ParsePosition(0))); This works though, but I