Questions tagged [numeric]

This tag is for questions concerning problems using numbers which either cannot be exactly solved, or where the exact solution may be much more difficult to acquire than by using numerical methods.

This tag is for questions concerning problems using numbers which either cannot be exactly solved, or where the exact solution may be much more difficult to acquire than by using numerical methods.

It includes questions about algorithms, precision and accuracy of underlying numbers, advantages and disadvantages of several methods, error propagation, problems with the underlying numbers and data structures.

2593 questions
78
votes
7 answers

How to validate numeric values which may contain dots or commas?

I need a regular expression for validation two or one numbers then , or . and again two or one numbers. So, these are valid inputs: 11,11 11.11 1.1 1,1
user256034
  • 4,289
  • 5
  • 37
  • 44
71
votes
23 answers

angularjs: allows only numbers to be typed into a text box

In angularjs is there any functionality available that allows only numbers to be typed into a text box like
Ali Hasan
  • 713
  • 1
  • 5
  • 4
61
votes
6 answers

Right way to convert data.frame to a numeric matrix, when df also contains strings?

I have a data frame taken from a .csv-file which contains numeric and character values. I want to convert this data frame into a matrix. All containing information is numbers (the non-number-rows I deleted), so it should be possible to convert the…
PikkuKatja
  • 1,101
  • 3
  • 13
  • 21
58
votes
4 answers

PHP - Get array value with a numeric index

I have an array like: $array = array('foo' => 'bar', 33 => 'bin', 'lorem' => 'ipsum'); echo native_function($array, 0); // bar echo native_function($array, 1); // bin echo native_function($array, 2); // ipsum So, this native function would return a…
thom
  • 581
  • 1
  • 4
  • 3
57
votes
3 answers

Set up dot instead of comma in numeric values

I have new XmlDocument object, i.g. xml is created during my program... I want all numeric values in created xml was with dot symbol instead of comma by default. Can I do something to declare it once, not to parse every decimal value? I.e. To set up…
Ksice
  • 3,277
  • 9
  • 43
  • 67
56
votes
4 answers

Difference between DECIMAL and NUMERIC

What's the difference between the SQL datatype NUMERIC and DECIMAL ? If databases treat these differently, I'd like to know how for at least: SQL Server Oracle Db/2 MySQL PostgreSQL Furthermore, are there any differences in how database drivers…
leeeroy
  • 11,216
  • 17
  • 52
  • 54
53
votes
7 answers

Associativity math: (a + b) + c != a + (b + c)

Recently I was going through an old blog post by Eric Lippert in which, while writing about associativity he mentions that in C#, (a + b) + c is not equivalent to a + (b + c) for certain values of a, b, c. I am not able to figure out for what…
Vaibhav Singla
  • 832
  • 1
  • 10
  • 14
51
votes
12 answers

IsNumeric function in c#

I know it's possible to check whether the value of a text box or variable is numeric using try/catch statements, but IsNumeric is so much simpler. One of my current projects requires recovering values from text boxes. Unfortunately, it is written…
user3352070
  • 585
  • 1
  • 4
  • 9
50
votes
11 answers

How to get bc to handle numbers in scientific (aka exponential) notation?

bc doesn't like numbers expressed in scientific notation (aka exponential notation). $ echo "3.1e1*2" | bc -l (standard_in) 1: parse error but I need to use it to handle a few records that are expressed in this notation. Is there a way to get bc to…
Ferdinando Randisi
  • 4,068
  • 6
  • 32
  • 43
47
votes
6 answers

How to convert character of percent into numeric in R

I have data with percent signs (%) that I want to convert into numeric. I run into a problem when converting character of percentage to numeric. E.g. I want to convert "10%" into 10%, but as.numeric("10%") returns NA. Do you have any ideas?
Frank Wang
  • 1,462
  • 3
  • 17
  • 39
44
votes
2 answers

How do I convert certain columns of a data frame to become factors?

Possible Duplicate: identifying or coding unique factors using R I'm having some trouble with R. I have a data set similar to the following, but much longer. A B Pulse 1 2 23 2 2 24 2 2 12 2 3 25 1 1 65 1 3 45 Basically, the first 2 columns are…
math11
  • 537
  • 2
  • 6
  • 8
41
votes
4 answers

What is integer overflow in R and how can it happen?

I have some calculation going on and get the following warning (i.e. not an error): Warning messages: 1: In sum(myvar, na.rm = T) : Integer overflow - use sum(as.numeric(.)) In this thread people state that integer overflows simply don't happen.…
Matt Bannert
  • 27,631
  • 38
  • 141
  • 207
41
votes
5 answers

SQLite ORDER BY string containing number starting with 0

as the title states: I have a select query, which I'm trying to "order by" a field which contains numbers, the thing is this numbers are really strings starting with 0s, so the "order by" is doing this... ... 10 11 12 01 02 03 ... Any…
Bigger
  • 1,807
  • 3
  • 18
  • 28
40
votes
5 answers

Java For-loop changes numeric result when changing type of loop variable

I wrote a program to calculate the PI number with Leibniz formula: [ I wrote a for-loop with type of initialization is "int" , the loop works fine but when i changed the initialization type to "long" the result is changed. This only happens when the…
programer310
  • 399
  • 3
  • 8
39
votes
0 answers

Why does Perl think "0 but true" is a number?

Scalar::Util's looks_like_number seems to be the commonly suggested way to determine whether a string is a number. Why does it consider the string "0 but true" to be a number ? use Scalar::Util 'looks_like_number'; print looks_like_number("0 but…
planetp
  • 14,248
  • 20
  • 86
  • 160