numbers

Store int32_t in an NSDictionary

Hi, How can I store a variable of type int32_t (e.g. for ABPropertyID) in an NSDictionary? [NSNumber numberWithInt:...] doesn't seem to work. Thanks From the comments: NSLog(@" %@ %@ ", [NSNumber numberWithLong:kABPersonFirstNameProperty], kABPersonFirstNameProperty); Prints: 0 (null) Any ideas? ...

Storing multiple values in a single cell in MySQL

I'm storing multiple numbers in a MySQL cell by using a delimiter (eg "1,5,10") and the TEXT datatype. How do I perform lookups like this? SELECT * FROM MyTable WHERE MultiVals CONTAINS "5" And lastly, is this the preferred approach to store such values? I'm using this like a linker table, to link certain rows to multiple other rows ...

Is there a way in Matlab using the pseudo number generator to generate numbers within a specific range?

For example: round(7*rand(1,5)) Generates 5 numbers between 1 and 7 Is there a way to generate 5 random numbers between 5 and 7? Or an abstraction of that? ...

How to import data from a file as an array in Mathematica?

I am trying to import a data set to Mathematica. The problem is that I cannot have the imported data as regular numbers in Mathematica. They are imported as "list". So, I cannot use them in the equations I need: Import["out.dat", "Data"] {{5.7, 4.3}, {-1.2, 7.8}} Array[cc, {2, 2}] For[i = 1, i <= 2, i++, For[j = 1, j <= 2, j++, cc[...

How do I make a page generate and display four random numbers in the 0 to 9 range?

<html> <body> <div style="text-align:center"><h2>Lucky Mo's Gift to You</h2> <p>Numbers rule our lives. If you would like the benefit of Lucky Mo's amazing powers of prognostication, click on the button below to receive your guaranteed lucky number of the day!</p> <input type="button" value="Click Here For Today's Pick-4 Winner" oncli...

Is there a "Number" struct/class in .NET?

I am attempting to store a variable length number that can have leading zeros as a part of that number. Is there a class in the .NET framework capable of storing values like this without losing information about leading zeros, and could surpass the upper limit of a long? I am currently storing them in a class like this, is there any wa...

Most efficient way to extract all the (natural) numbers from a string

Users may want to delimit numbers as they want. What is the most efficient (or a simple standard function) to extract all the (natural) numbers from a string? ...

Tricky number sorting question in Java. How to sort ascending using if's?

So I am in a Java class in school, and I have a relatively simple assignment that I just can't figure out. It's not a problem to research the answer, so I am throwing it out to the brightest people out there. My simple java program takes 4 numbers as input, and then it is just supposed to spit those numbers right back out, but in order s...

Python: range and xrange for 13-digit numbers?

range() and xrange() work for 10-digit-numbers. But how about 13-digit-numbers? I didn't find anything in the forum. Thanks in advance. ...

PHP check if variable is a whole number

I have this PHP code: $entityElementCount = (-($highScore-$totalKeywordCount))/0.29; What i want to know is, how to check whether $entityElementCount is a whole number (2, 6, ...) or partial (2.33, 6.2, ...). Thank you! ...

Regular expression for accepting alphnumeric characters (6-10 chars) .NET, C#

I am building a user registration form using C# with .NET. I have a requirement to validate user entered password fields. Validation requirement is as below. It should be alphanumeric (a-z , A-Z , 0-9) It should accept 6-10 characters (minimum 6 characters, maximum 10 characters) With at least 1 alphabet and number (example: stack1ove...

ISO-8601 week numbering vs "Outlook" numbering in PHP

I recently came across a big problem, as I have a system that's paying the customers weekly. As we all know, a year has 52 weeks, and there are standards for it. I'm using PHP aka date('W') to get the week number from a date, that calculates that according to the standard ISO-8601. Here are some references: http://www.iso.org/iso/da...

Adventurous: Patching VS.NET to include line numbers in release builds

I am distributing with VS 2008 .NET and obfuscation. I am up against the frustrating problem of not being able to see line numbers in stack traces. Whilst there are workarounds eg. http://stackoverflow.com/questions/1328836/include-line-numbers-in-stack-trace-without-pdb when the stack traces are returned (holding PDB files locally et...

PHP: Simple regular expressions to match length?

I'm creating a registration system that needs to check the name/pass etc. with REGEX (and prefer to), what I've got so far is: //Check so numbers aren't first, such as 00foobar preg_match('/^(?!\d)[a-z0-9]+$/iD',$usrname); //Just simple check preg_match('/^[a-zA-Z0-9]+$/',$psword); But I have to do stupid things in IF statements like:...

round decimal values up to the nearest of 0.01?

Hi, How to round decimal value up to nearest 0.05 value??, the linked SO post also discusses the similar topic, but its not the output i expected. I need to convert the decimal values like this 16.489-->16.49 16.482-->16.48 16.425-->16.43 7.67 --> 7.67 (no conversion) I can use the below C# method to convert the values Math.Round...

How do I check if a string has at least one number in it using Ruby?

I need to check to see if a string contains at least one number in it using Ruby (and I assume some sort of regex?). How would I do that? ...

Getting Numbers From A CFDictionary For Use In Calculations, iPhone

Hello all, I found this in my travels: http://www.opensource.apple.com/source/IOKitUser/IOKitUser-502/ps.subproj/IOPSKeys.h How would I get the values (as a number) of: #define kIOPSMaxCapacityKey "Max Capacity" and #define kIOPSDesignCapacityKey "DesignCapacity" I want to be able to use them throughout my app. What do I need to...

String to int - cocoa, objective-c

I'm trying to get a value from a NSTextField (Label) and convert it to a int... minFormatter = [[NSNumberFormatter alloc] init]; [minFormatter setNumberStyle:NSNumberFormatterNoStyle]; NSNumber *minTimeValue = [minFormatter numberFromString:[NSString stringWithFormat:@"%@", [self.minTextLabel stringValue]]]; [minFormatter release...

xslt format-number decimal, number less than one

I have this as input called $material_price: 2.40 1000 0.60 They run through <!-- setup currency rendering --> <xsl:decimal-format name="dkk" decimal-separator="," grouping-separator="."/> <xsl:value-of select="format-number($material_price, '#.###,00', 'dkk')"/> Output is: 2,40 1.000,00 ,60 How can I make changes to the xslt so...

How to parse numeric value in string representation in Cocoa?

As the title. I tested NSScanner, but it passed some strange strings. (ex :123aaa). Is there any way to convert string<->number strictly? ...