numbers

How to localize numerals?

Ok, I'm using mathematical equations to output numbers, though, I need this to be compatible for all languages. Currently, all language strings are within a php array called $txt, and each key of the array gets called for that language. I'm outputting the following: Column 1, Column 2, Column 3, and so on, as well as Row 1, Row 2, Row...

Python- Convert a mixed number to a float

I want to make a function that converts mixed numbers and fractions (as strings) to floats. Here's some examples: '1 1/2' -> 1.5 '11/2' -> 5.5 '7/8' -> 0.875 '3' -> 3 '7.7' -> 7.7 I'm currently using this function, but I think it could be improved. It also doesn't handle numbers that are already in decimal representation def mixedt...

iPhone: How to Extract a Numerical Value from a String?

Is it possible to extract a number from a string. For example, I have a string: my name is shishir and my number is 98890876478 Can I extract on 98890876478 from the above string? Or if my string is: my name is shishir and my number is XXX98890876478XXX In this condition can I extract `98890876478", which is in between of XXX. Is...

Possible to Retrieve Device's Phone Number Automatically In Android?

Ey guys, I am wondering if it is possible to retrieve device's phone number via the Android API(specifically 1.5 API). Thanks in advance! ...

What does this number mean?

I have one number that has something related to the currentdate : 634101448539930000 634101448627430000 (this information was took 9 seconds later than the first one) I have many codes like this and I need to know what those number means. It's something related to the current time, because the new information has always a bigger number...

Decoding relationship between two numbers?

Is there any way (or calculator) to determine the relationship between two numbers. ...

Formatting numbers in loop

I want to list all numbers from 0000-9999 however I am having trouble holding the zero places. I tried: for(int i = 0; i <= 9999; ++i) { cout << i << "\n"; } but I get: 1,2,3,4..ect How can I make it 0001,0002,0003....0010, etc ...

Separating arguments to a function, in locales with comma as decimal marker

In locales, e.g. French, with comma as decimal indicator (where "5,2" means five and two-tenths), how do users separate function arguments from each other? For example, in many programming/scripting languages, I could specify MAX(1.5, X) in a EN-US locale. How do you avoid the ambiguity between the comma as decimal indicator, and as ...

how to print number with commas as thousands separators in Javascript

I am trying to print an integer in Javascript with commas as thousands separators. For example, I want to show the number 1234567 as "1,234,567". How would I go about doing this? Here is how I am doing it: function numberWithCommas(x) { x = x.toString(); var pattern = /(-?\d+)(\d{3})/; while (pattern.test(x)) x = x.r...

Optimizing this "Boundarize" method for Numerics in Ruby

I'm extending Numerics with a method I call "Boundarize" for lack of better name; I'm sure there are actually real names for this. But its basic purpose is to reset a given point to be within a boundary. That is, "wrapping" a point around the boundary; if the area is betweeon 0 and 100, if the point goes to -1: -1.boundarize(0,100) ...

Are there any libraries for parsing "number expressions" like 1,2-9,33- in Java

Hi, I don't think it is hard, just tedious to write: Some small free (as in beer) library where I can put in a String like 1,2-9,33- and it can tell me whether a given number matches that expression. Just like most programs have in their print range dialogs. Special functions for matching odd or even numbers only, or matching every numb...

How To Convert Arabic Number Ascii Code to String in ROR ?

I want to convert my English Numbers Pager to an Arabic one, I had something like <% @engnum = "0123456789" %> <% @arabnum = "٠١٢٣٤٥٦٧٨٩" %> <%= (@pagenumber).to_s.gsub(/./) {|s| @arabnum[@engnum.index(s)]} %> But this shows the ascii number not the actual number i need Any idea how to show the actual string (Number) Remember that...

How to declare number in C#?

In as3 I'd say public var time:Number; How to declare such in C#? ...

Prolog: find all numbers of unique digits that can be formed from a list of digits

The best thing I could come up with so far is this function: numberFromList([X], X) :- digit(X), !. numberFromList(List, N) :- member(X, List), delete(List, X, LX), numberFromList(LX, NX), N is NX * 10 + X. where digit/1 is a function verifying if an atom is a decimal digit. The numberFromLis...

How to turn Bytes into number (IEEE754 to number) Actionscript

How to write such C# code in Actionscript? Console.WriteLine(BitConverter.ToDouble(new byte[8] { 0x77, 0xBE, 0x9F, 0x1A, 0x2F, 0x0D, 0x4F, 0x40 }, 0)); ...

How are negative numbers represented in 32-bit signed integer?

How are negative number represented in 32-bit signed integer? Is it two's or one's complement? or the last bit on the left is like a flag? For example: (-10) ...

bit manipulation in java

I have a fragment of bytes in a byte[]. The total size of the array is 4 and I want to convert this into a positive long number. For example if the byte array is having four bytes 101, 110, 10, 10000001 then i want to get the long number represented by binary sequence 00000000 00000000 00000000 00000000 00000101 00000110 00000010 10000...

Help with float numbers in Java

Hi, Could anyone please me why the output of the following programme is not " different different"? public static void main(String[] args) { float f1=3.2f; float f2=6.5f; if(f1==3.2) System.out.println("same"); else System.out.println("different"); if(f2==6.5) System.out.println("same"); else System.out.println("different"); } o/p ...

Averaging increasing number of variables

Hi! I have to report average value of incoming numbers, how i could do that without using some sort of data structure to keep track of all values and then calculating average by summing them and dividing by number of values? ...

Need a regular expression for an Irish phone number

I need to validate an Irish phone number but I don't want to make it too user unfriendly, many people are used to writing there phone number with brackets wrapping their area code followed by 5 to 7 digits for their number, some add spaces between the area code or mobile operator. The format of Irish landline numbers is an area code of ...