number-formatting

android: how do I format number as phone with parentheses

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 04:13:13
问题 I have a number that I need to format as a telephone number. If I do PhoneNumberUtils.formatNumber(numStr); Then I get 888-555-1234 But what I need to get is (888) 555-1234 How do I get the second one? Is there a standard android way? 回答1: If you know the country for which you want to do it, you can use Google's open source library libphonenumber . Here is how you can format it: String numberStr = "8885551234" PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance(); try { PhoneNumber

C++ complex numbers, what is the right format?

时光怂恿深爱的人放手 提交于 2019-12-30 00:07:25
问题 I want to use C++ with complex numbers. Therefore I included #include <complex> . Now my question is: How do I declare a variable?(so what is the format called for let's say: 1 + i ?) Thanks in advance :-) 回答1: // 1 + 2i std::complex<double> c(1, 2); 回答2: The constructor of std::complex has two parameters: The first, wich has the real part of the number. The second, wich has the imaginary part of the number. For example: std::complex<float> my_complex(1,1); //1 + 1i Also, C++11 introduces

Convert float to string in positional format (without scientific notation and false precision)

浪尽此生 提交于 2019-12-29 10:53:48
问题 I want to print some floating point numbers so that they're always written in decimal form (e.g. 12345000000000000000000.0 or 0.000000000000012345 , not in scientific notation, yet I'd want to the result to have the up to ~15.7 significant figures of a IEEE 754 double, and no more. What I want is ideally so that the result is the shortest string in positional decimal format that still results in the same value when converted to a float . It is well-known that the repr of a float is written in

Convert float to string in positional format (without scientific notation and false precision)

感情迁移 提交于 2019-12-29 10:53:15
问题 I want to print some floating point numbers so that they're always written in decimal form (e.g. 12345000000000000000000.0 or 0.000000000000012345 , not in scientific notation, yet I'd want to the result to have the up to ~15.7 significant figures of a IEEE 754 double, and no more. What I want is ideally so that the result is the shortest string in positional decimal format that still results in the same value when converted to a float . It is well-known that the repr of a float is written in

phpExcel write long number in cell

混江龙づ霸主 提交于 2019-12-29 04:23:24
问题 While writing the excel file is fine I see that really long numbers are formulas in excel Example: 8.71129E+12 instead of: 1234567890 How can I change the format during the PHP Excel Creation? I'm following the simple example here 回答1: $objPHPExcel->getActiveSheet()->setCellValueExplicit('A1', '1234567890', PHPExcel_Cell_DataType::TYPE_STRING); 回答2: Either set the value explicitly as a string, or set a number format mask for the cell that forces display of all digits (e.g. '#,##0' 0r '0')

In jQuery, what's the best way of formatting a number to 2 decimal places?

孤街浪徒 提交于 2019-12-27 13:39:34
问题 This is what I have right now: $("#number").val(parseFloat($("#number").val()).toFixed(2)); It looks messy to me. I don't think I'm chaining the functions correctly. Do I have to call it for each textbox, or can I create a separate function? 回答1: If you're doing this to several fields, or doing it quite often, then perhaps a plugin is the answer. Here's the beginnings of a jQuery plugin that formats the value of a field to two decimal places. It is triggered by the onchange event of the field

In jQuery, what's the best way of formatting a number to 2 decimal places?

淺唱寂寞╮ 提交于 2019-12-27 13:38:53
问题 This is what I have right now: $("#number").val(parseFloat($("#number").val()).toFixed(2)); It looks messy to me. I don't think I'm chaining the functions correctly. Do I have to call it for each textbox, or can I create a separate function? 回答1: If you're doing this to several fields, or doing it quite often, then perhaps a plugin is the answer. Here's the beginnings of a jQuery plugin that formats the value of a field to two decimal places. It is triggered by the onchange event of the field

Add 'decimal-mark' thousands separators to a number

谁说我不能喝 提交于 2019-12-27 11:44:21
问题 How do I format 1000000 to 1.000.000 in Python? where the '.' is the decimal-mark thousands separator. 回答1: If you want to add a thousands separator, you can write: >>> '{0:,}'.format(1000000) '1,000,000' But it only works in Python 2.7 and higher. See format string syntax. In older versions, you can use locale.format(): >>> import locale >>> locale.setlocale(locale.LC_ALL, '') 'en_AU.utf8' >>> locale.format('%d', 1000000, 1) '1,000,000' the added benefit of using locale.format() is that it

not getting the proper output in number format

半腔热情 提交于 2019-12-25 19:58:14
问题 I am formating numbers in locale US . The problem i am facing is that it's not displaying the exact number user gives rather it's displaying upto 8 digit number. In the childview it shows the user input but when i try to display it i n the groupview it's displaying only 8 digits Code: NumberFormat numberFormat= NumberFormat.getNumberInstance(locale); numberFormat.format(double);// double is the user given input 回答1: The problem is that double cannot hold so many significant digits (mantissa).

Number values changing when toString() applied

落爺英雄遲暮 提交于 2019-12-25 06:59:05
问题 I am noticing something very strange when testing one of my functions that checks the validity of numbers, I first noticed it when testing the 'number.toString()[0]'. If I console logged (fLetter(019272)); the '0' is always showing '1'. After checking online I couldn't find any issues associated with using the toString() method on numbers containing '0'. function numberValidate(number) { var numCheck = [0, 5, 7, 8, 9]; var fLetter = number.toString()[0]; if (number.match(/^\d{6}$/)) { for