comma

How can I set the decimal separator to be a comma?

不问归期 提交于 2019-11-27 14:09:12
I would like to read and write pi as 3,141592 instead of 3.141592 , as using the comma is common in many European countries. How can I accomplish this with iostream s? In other words cout << 3.141592; should print 3,141592 to standard output. You should use basic_ios::imbue to set the preferred locale. Take a look here: http://www.cplusplus.com/reference/ios/ios_base/imbue/ Locales allow you to use the preferred way by the user, so if a computer in Italy uses comma to separate decimal digits, in the US the dot is still used. Using locales is a Good Practice. But if you want to explicitly force

HTML5 input box with type=“number” does not accept comma in Chrome browser

雨燕双飞 提交于 2019-11-27 14:04:40
I am using a HTML5 input box with type="number" . Regarding to some documentations, it should be possible to enter a number with comma (not with period) if I also use the lang="" attribute. It is working in Firefox, but not in Chrome (does not accept a comma). How can I get Chrome to accept the comma in the input box. My problem is that our German users expect that they can enter a comma instead of a period there. https://jsfiddle.net/byte2702/y3Lpfw7m/ Please enter a number with comma: <br/> <input id="num" type="number" step="any" lang="de" pattern="-?[0-9]+[\,.]*[0-9]+" /> As of now (30/08

Removing last comma from a foreach loop

痴心易碎 提交于 2019-11-27 08:28:05
Im using a foreach loop to echo out some values from my database and seperating each of them by commas but I dont know how to remove the last comma it adds on the last value. My code is pretty simple but I just cant seem to find the correct way of doing this: foreach ($this->sinonimo as $s){ echo '<span>'.ucfirst($s->sinonimo).',</span>'; } Thanks in advance for any help :) Put your values in an array and then implode that array with a comma (+ a space to be cleaner): $myArray = array(); foreach ($this->sinonimo as $s){ $myArray[] = '<span>'.ucfirst($s->sinonimo).'</span>'; } echo implode( ',

C++ CSV line with commas and strings within double quotes

主宰稳场 提交于 2019-11-27 08:05:16
问题 I'm reading a CSV file in C++ and the row format is as such: "Primary, Secondary, Third", "Primary", , "Secondary", 18, 4, 0, 0, 0 (notice the empty value) When I do: while (std::getline(ss, csvElement, ',')) { csvColumn.push_back(csvElement); } This splits up the first string into pieces which isn't correct. How do I preserve the string when iterating? I tried to do a combination of the above and while also grabbing the lines separated by double quote but I got wild results. 回答1: You need to

Split up NSString using a comma

懵懂的女人 提交于 2019-11-27 07:45:13
I have a JSON feed connected to my app. One of the items is lat & long separated by a comma. For example: "32.0235, 1.345". I'm trying to split this up into two separate values by splitting at the comma. Any advice? Thanks!! NSArray *strings = [coords componentsSeparatedByString:@","]; NSString* myString = @"32.0235, 1.345". NSArray* myArray = [myString componentsSeparatedByString:@","]; NSString* firstString = [myArray objectAtIndex:0]; NSString* secondString = [myArray objectAtIndex:1]; See in documentation You want: - (NSArray *)componentsSeparatedByString:(NSString *)separator using @","

What is the point of wrapping JavaScript statements in parentheses?

旧街凉风 提交于 2019-11-27 07:18:11
问题 I have discovered that wrapping different statements in parentheses will return the last one: (34892,47691876297,2000) => 2000 ('test',73,document.createElement('p')) => <p></p> And I also found out that all the statements are executed anyway: (console.log('test'), console.log('test2'), console.log('test3'), 6) Will log: test test2 test3 And the result will be 6. However, I've also found that some statements can't be used: (throw new Error(), 10) => SyntaxError: Unexpected token throw (if (1)

comma separated string of selected values in mysql

倾然丶 夕夏残阳落幕 提交于 2019-11-27 07:10:14
I want to convert selected values into a comma separated string in MySQL. My initial code is as follows: SELECT id FROM table_level where parent_id=4; Which produced: '5' '6' '9' '10' '12' '14' '15' '17' '18' '779' My desired output would look like this: "5,6,9,10,12,14,15,17,18,779" Check this SELECT GROUP_CONCAT(id) FROM table_level where parent_id=4 group by parent_id; Sanal K If you have multiple rows for parent_id. SELECT GROUP_CONCAT(id) FROM table_level where parent_id=4 GROUP BY parent_id; If you want to replace space with comma. SELECT REPLACE(id,' ',',') FROM table_level where parent

Split a String at every 3rd comma in Java

蓝咒 提交于 2019-11-27 05:27:32
I have a string that looks like this: 0,0,1,2,4,5,3,4,6 What I want returned is a String[] that was split after every 3rd comma, so the result would look like this: [ "0,0,1", "2,4,5", "3,4,6" ] I have found similar functions but they don't split at n-th amount of commas. Pshemo You can try to use split method with (?<=\\G\\d+,\\d+,\\d+), regex Demo String data = "0,0,1,2,4,5,3,4,6"; String[] array = data.split("(?<=\\G\\d+,\\d+,\\d+),"); //Magic :) // to reveal magic see explanation below answer for(String s : array){ System.out.println(s); } output: 0,0,1 2,4,5 3,4,6 Explanation \\d means

PHP remove commas from numeric strings

老子叫甜甜 提交于 2019-11-27 05:13:54
In PHP, I have an array of variables that are ALL strings. Some of the values stored are numeric strings with commas. What I need: A way to trim the commas from strings, and ONLY do this for numeric strings. This isn't as straightforward as it looks. The main reason is that the following fails: $a = "1,435"; if(is_numeric($a)) $a = str_replace(',', '', $a); This fails because $a = "1435" is numeric. But $a = "1,435" is not numeric. Because some of the strings I get will be regular sentences with commas, I can't run a string replace on every string. Not tested, but probably something like if

Split comma separated values of a column in row, through Oracle SQL query

二次信任 提交于 2019-11-27 04:41:58
I have a table like below: ------------- ID | NAME ------------- 1001 | A,B,C 1002 | D,E,F 1003 | C,E,G ------------- I want these values to be displayed as: ------------- ID | NAME ------------- 1001 | A 1001 | B 1001 | C 1002 | D 1002 | E 1002 | F 1003 | C 1003 | E 1003 | G ------------- I tried doing: select split('A,B,C,D,E,F', ',') from dual; -- WILL RETURN COLLECTION select column_value from table (select split('A,B,C,D,E,F', ',') from dual); -- RETURN COLUMN_VALUE Try using below query: WITH T AS (SELECT 'A,B,C,D,E,F' STR FROM DUAL) SELECT REGEXP_SUBSTR (STR, '[^,]+', 1, LEVEL) SPLIT