numbers

How can I convert a number to text in Perl?

I need some code in my program which takes a number as input and converts it into corresponding text e.g. 745 to "seven hundred forty five". Now, I can write code for this, but is there any library or existing code I can use? ...

How to sort digits in a number?

I'm trying to make an easy script in Python which takes a number and saves in a variable, sorting the digits in ascending and descending orders and saving both in separate variables. Implementing Kaprekar's constant. It's probably a pretty noobish question. But I'm new to this and I couldn't find anything on Google that could help me. A...

How can I check for the correct location of commas in a number entered by a user?

I'm looking for a good way to check a number that a user has entered for correct position of an optional comma(s). For example 1,000,000.00 = correct 1000000 = correct 1,00,000.00 = incorrect ,100,000 = incorrect So it looks like i need to check to see that there is at least one number to the left and 3 numbers to the right of the com...

What Letter and Number Mixups Need to be Considered?

I just had a user tell me his registration key didn't work. It took me quite a while to figure out that he entered the capital letter "O" instead of the number "0". So I decided that it is best for my registry checker to treat both "O" and "0" as equivalent, so both will work. I can think of two other possible mixups: The number "1...

Detecting if a given number is an integer

Hello, what seems to be a simple question turns out as a difficult task to me. I need this: if (number == integer) if (1.589 == integer) // false if (2 == integer) // true Any clues? ...

How can I add a contact to Blackberry web application using JavaScript (if possible)?

I need to develop an application, which adds telephone numbers to existing or new contacts in Blackberry. The application is preferrably a web application. Is it possible to add and read contact information on Blacberry devices using JavaScript? If yes, a code sample would be appreciated. ...

Extract first two digits of hex (UInt32 *) and convert to int

I have a bunch of hex values stored as UInt32* 2009-08-25 17:09:25.597 Particle[1211:20b] 68000000 2009-08-25 17:09:25.598 Particle[1211:20b] A9000000 2009-08-25 17:09:25.598 Particle[1211:20b] 99000000 When I convert to int as is, they're insane values when they should be from 0-255, I think. I think I just need to extract the firs...

how to create unique integer number from 3 different integers numbers(1 Oracle Long, 1 Date Field, 1 Short)

the thing is that, the 1st number is already ORACLE LONG, second one a Date (SQL DATE, no timestamp info extra), the last one being a Short value in the range 1000-100'000. how can I create sort of hash value that will be unique for each combination optimally? string concatenation and converting to long later: I don't want this, for ...

Best algorithm for hashing number values?

When dealing with a series of numbers, and wanting to use hash results for security reasons, what would be the best way to generate a hash value from a given series of digits? Examples of input would be credit card numbers, or bank account numbers. Preferred output would be a single unsigned integer to assist in matching purposes. My ...

C# - Excel Number Formatting Issue with International settings

I am trying to write to an Excel 2003 spreadsheet using c# 3.5. However I am unable to get this to function correctly across different country settings. The country settings are either English or German. These two settings have different decimal and thousands settings. Everything works fine unless a user has changed the decimal and thous...

Formatting a large number with commas

I need to format a number so that there is a comma seperating the thousands place for any number over and including 10000. eg 10000 becomes 10,000 but 9999 remaains as 9999. I would like to do this using a format string as I do not want to have to test the data to see if what range it is in. Does anyone know how to do this? ...

What is &H14& in VBScript?

I found the following article : here about installing fonts on a Windows computer via a script. The author uses VBScript to do that, but I'd like to use Ruby/Python. There is a line in the script I don't understand : Const FONTS = &H14& What is that &H14&? Is it a number? How would I represent that in another language? ...

C# numeric base class

I want to write a C# method that can accept any number. Something like: public static T Sum(T a, T b) where T : number { // (not real code) return a + b; } But I don't see a "number" base class in C#, as exists in most other languages I've used. The numeric value types are IComparable, IFormattable, IConvertible, IComparable, a...

Generating Random Numbers in Objective C for iPhone SDK

I was using the arc4random() function in order to generate a random group and sequence of numbers, but I was told that this was overkill and that I should use the random() function instead. However, the random() function gives me the same group and sequence of numbers every time. I call srand(time(0)) once when my app first starts in or...

How to format numbers according to locale in Haskell?

In Python I can use locale.format to pretty-print numbers according to locale setting: >>> import locale >>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8") 'en_US.UTF-8' >>> locale.format("%.2f",1234567.89,grouping=True) '1,234,567.89' How can I do the same in Haskell? I see that there are localeconv and setlocale bindings, but is the...

How do I check for numeric overflow and underflow conditions in Perl?

Hi All, I am doing one multiplication operation between two float variables. After that i need to check for numeric overflow, underflow and divide by zero errors if any. How I can do this? ...

How to convert number to natural language string?

Is there any existing builtin (or third party) Java class or library that can convert numbers to natural language strings; e.g. 1 -> "one", 2 -> "two", 1256 -> "a one thousand two hundred and fifty-six", etc.? ...

Rounding off decimals in Django

I want to round off my decimal values as below: 7,715.625 becomes 7,716 How do I achieve this? ...

How to verify input in UITextField (i.e., numeric input)

Hello all, I am fairly new to iPhone development and I have what seems to be a simple question that I cannont figure out. How can I verify that a user input a number and a decimal into the text field? I have tried many different things but the closes I can get only allows for numeric strings of the form: 5.34 or 23.89. I need it to ...

How do you set, clear and toggle a single bit in JavaScript?

How to set, clear, toggle and check a bit in JavaScript? ...