numbers

Need a simple RegEx to find a number in a single word

Hi Folks, I've got the following url route and i'm wanting to make sure that a segment of the route will only accept numbers. as such, i can provide some regex which checks the word. /page/{currentPage} so.. can someone give me a regex which matches when the word is a number (any int) greater than 0 (ie. 1 <-> int.max). cheers! ...

.Net Converting a number from one culture to another

Quick question -- In .Net (VB more specifically, but that doesn't really matter), is there a way to change the format of a number from one culture to another strictly through the that number's type? The issue is this: In English, the number is say, 123.45. Whereas in Sweden, the number would be 123,45 Is there a way to convert 123,4...

Replace non-numeric with empty string

Quick add on requirement in our project. A field in our DB to hold a phone number is set to only allow 10 characters. So, if I get passed "(913)-444-5555" or anything else, is there a quick way to run a string through some kind of special replace function that I can pass it a set of characters to allow? Regex? ...

Defining different types of numbers in C#

You can define a number in various ways in C#, 1F // a float with the value 1 1L // a long with the value 1 1D // a double with the value 1 personally I'm looking for which would a short, however to make the question a better reference for people, what are all the other post-fix's to number literals you can apply? ...

Is there a VB.NET function to format a number as an Ordinal

Hello, The title says it all really, is there a built in VB.NET function to format a number as an Ordinal? Or do I have to write my own? There isn't in C# so I'm thinking their isn't :( Thanks ...

Is there some list of input's IDs or names of Form after the script was sent?

Hi, Let's imagine I got this: index.php generates form with unpredictable number of inputs with certain IDs/Names and different values that can be edited by user and saved by script.php <form action="script.php" method="post"> <input id="1" name="1" type="text" value="1"/> <input id="24" name="24" type="text" value="2233"/> <input id=...

Is there an easy way to convert a number to a word in PHP?

In PHP, is there an easy way to convert a number to a word? For instance, 27 to twenty-seven. ...

Is there a good reason for storing percentages that are less than 1 as numbers greater than 1?

I inherited a project that uses SQL Server 200x, wherein a column that stores a value that is always considered as a percentage in the problem domain is stored as its greater than 1 decimal equivalent. For example, 70% (0.7, literally) is stored as 70, 100% as 100, etc. Aside from the need to remember to * 0.01 on retrieved values and * ...

Phone Number Columns in a Database

In the last 3 companies I've worked at, the phone number columns are of type varchar(n). The reason being that they might want to store extensions (ext. 333). But in every case, the "-" characters are stripped out when inserting and updating. I don't understand why the ".ext" characters are okay to store but not the "-" character. Has an...

regex compare two numbers

can i somehow compare two numbers in regex? i want regex that is correct for 10-12, but incorrect for 12-10. I mean that 10 must be smaller than 12. I want to do it in Javascript. ...

Number VS Varchar(2) Primary Keys

I'm now to this point of my project that I need to design my database (Oracle). Usually for the status and countries tables I don’t use a numeric primary key, for example STATUS (max 6) AC --> Active DE --> Deleted COUNTRIES (total 30) UK --> United Kingdom IT --> Italy GR --> Greece These tables are static, not updated through the a...

How does Perl decide to treat a scalar as a string or a number?

Consider the following code and its output: Code #!/usr/bin/perl -w use strict; use Data::Dumper; my $HOURS_PER_DAY = 24.0 * 1.0; my $BSA = 1.7 * 1.0; my $MCG_PER_MG = 1000.0 * 1.0; my $HOURS_DURATION = 20.0 * $HOURS_PER_DAY; my $dummy = $HOURS_PER_DAY * $BSA * $MCG_PER_MG * $HOURS_DURATION; print Dumper($HOURS_PER_DAY); print Dumpe...

Oracle Floats vs Number

I'm seeing conflicting references in Oracles documentation. Is there any difference between how decimals are stored in a FLOAT and a NUMBER types in the database? As I recall from C, et al, a float has accuracy limitations that an int doesn't have. R.g., For 'float's, 0.1(Base 10) is approximated as 0.110011001100110011001101(Base 2) wh...

Multiple questions on BIRT

Hi, I am new to BIRT. I have a requirement to print a HEADING based on a database value. How do I do that? How do I leave a Blank line upon break in one of the fields I am reporting? In the footer, I need to say "Page X of Y" where Y is the total number of pages? Your help is much appreciated - ASAP Thanks Nurani Sivakumar ...

Difference between 2 numbers

I need the perfect algorithm or C# function to calculate the difference (distance) between 2 decimal numbers. For example the difference between: 100 and 25 is 75 100 and -25 is 125 -100 and -115 is 15 -500 and 100 is 600 Is there a C# function or a very elegant algorithm to calculate this or I have to go and handle every case separate...

Math - mapping numbers

How do I map numbers, linearly, between a and b to go between c and d. That is, I want numbers between 2 and 6 to map to numbers between 10 and 20... but I need the generalized case. My brain is fried. ...

Piano (Peano) numbers?

Hey, I was listening to the steve yegge podcast (#29, around 21:29), and in part of it, they were talking about "how to tell if the person you're talking to is smart", and they said that one way was to talk about "smart people things" (I'm paraphrasing), like "piano numbers" and "lambda calculus". I'm secure enough to admit that I'm not ...

HTML to Excel: How can tell Excel to treat columns as numbers?

I need to achieve the following when opening an HTML in Excel (Response.contentType="application/vnd.ms-excel") : force Excel to consider content of td cells as numbers make the above so that any subsequent user-entered formulas work on these cells (when the spreadsheet is opened) So far I was successful with adding style="vnd.ms-exc...

Default Number of Decimal Places to Output in PHP

Hi all, I do my php work on my dev box at home, where I've got a rudimentary LAMP setup. When I look at my website on my home box, any numbers I echo are automatically truncated to the least required precision. Eg 2 is echoed as 2, 2.2000 is echoed as 2.2. On the production box, all the numbers are echoed with at least one unnecessar...

Most elegant way to detect if a String is a number?

Is there a better, more elegant (and/or possibly faster) way than boolean isNumber = false; try{ Double.valueOf(myNumber); isNumber = true; } catch (NumberFormatException e) { } ...? Edit: Since I can't pick two answers I'm going with the regex one because a) it's elegant and b) saying "Jon Skeet solved the problem" is a tau...