numbers

What is the 'd' in the literal 12d called?

I feel like I should know the answer to this, but I don't. What is the type character on a numeric literal called? double myDouble = 12d; float myFloat = 10f; I wanted to find a complete list of them today, but couldn't come up with what to ask Google to search for. EDIT Found a decent list if anyone is interested http://www...

Is there a more efficient way to organize random outcomes by size in Python?

(sorry if this is a dumb question, I'm still learning) I'm making a program that, for part of the prog, rolls four dice and subtracts the lowest dice from the outcome. The code I'm using is die1 = random.randrange(6) + 1 die2 = random.randrange(6) + 1 die3 = random.randrange(6) + 1 die4 = random.randrange(6) + 1 if die1 <= die2 and die...

When does the difference between a string and a number matter in Perl 5?

If a string in Perl 5 passes looks_like_number, it might as well be a number. For instance, my $s = "10" + 5; results in $s being assigned 15. Are there any cases where a string does not behave like it's numeric equivalent would have? ...

Extract number from string in MSBuild

I would like to extract the number from a string in MSBuild. How can I do that using the built in tasks or the MSBuild.Community.Tasks? (RegexMatch might do, but how?) Example: I have the string agent0076 and I would like to get out the number, without the leading zeros: 76 ...

Detecting whether number string or operator/letter string in PHP?

In PHP, how do I distinguish between a number as a string [0-9] versus an operator (+-*/) or letter [A-Za-z]? I tried this, but intval also converts the type of nonnumbers to ints as well: is_int(intval($somestr)); Is regex the way to do it? ...

Order by text and then by number

I have data like: Audio 1 Test File 10 Audio 2 Audio 3 File 11 Audio 1 Audio 13 Audio 22 File 20 Test Test File 22 Audio 10 File 1 File 2 I need it order first by the text (i.e. Audio, File, Test) and then by number (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 etc.) The problem is that sorti...

Designing small comparable objects

Intro Consider you have a list of key/value pairs: (0,a) (1,b) (2,c) You have a function, that inserts a new value between two current pairs, and you need to give it a key that keeps the order: (0,a) (0.5,z) (1,b) (2,c) Here the new key was chosen as the average between the average of keys of the bounding pairs. The problem is, t...

rng random number

Hi, I have a question. How can I calculate/estimate upper bound of random number, that a random number can generate ? Thanks in advance! ...

Format number as I type Expand this post

Hi I am working on an app at the moment that requires number input to be formatted as the textfield changes as well as perform a calculation. I have the text fields set up so that as the user types notifications are passed out and a calculation is performed. However what I need to do now is format the text to be in this style: €1,000,000...

Parsing numbers at PreviewTextInput

I have a WPF application in which I have a hook at PreviewTextInput, through that I get the currently entered character and I have the string already entered. Given this I need to write the following function : bool ShouldAccept(char newChar,string existingText) existingText can be comma seperated valid numbers(including exponential) ...

Filezilla won't connect to my server!

Hey guys! I'm awful with computers! I'm trying to use Filezilla to connect to my server. When I do this, this is the message it give me verbatim: Protocol error: Unknown protocol identifier (0x50 0x50 0x48). Most likely connected to the wrong port. Connection to server closed. but it's not the wrong port!... what am I doing wrong? ...

Enter a TAB after every Xth character of text

Hi, not necessarily a programmer question but I need to enter a TAB after every 84th character of a text. I'm trying to do it in InDesign but I don’t see an option for this. Is there a good application to do this? Preferably Mac OS X compatlible but Windows XP is fine too. Thank you very much! ...

How to Add values in a table together using jQuery?

I have an HTML table with number values. What i need to do is to get all these values and add them together using jQuery. Any ideas? Example table: http://pastie.org/998759 ...

How do I create a Numbers spreadsheet using objective-c?

I'm writing a Cocoa application and I'd like to generate a Numbers spreadsheet from my application using Scripting Bridge. I've generated the Numbers.h file and linked the ScriptingBridge.framework per the directions in Apple's Documentation. Below is the code I'm using to try to simply create a Numbers document and save it. NSString *...

Double type returns -1.#IND/NaN error when calculating pi iteratively

I am working through a problem for my MCTS certification. The program has to calculate pi until the user presses a key, at which point the thread is aborted, the result returned to the main thread and printed in the console. Simple enough, right? This exercise is really meant to be about threading, but I'm running into another problem. T...

ruby number to human-readable string conversion

I need to have a list with id's for each list item being #one, #two etc. Is this the most efficient way or am I missing an in built ruby function here? -num_array = ["one", "two", "three", "four", "five", "six", "seven"] -navigation[:primary_level].each_with_index do |primary_item, idx| %li{ :id => "#{num_array[idx]}"} ...

A function where small changes in input always result in large changes in output

I would like an algorithm for a function that takes n integers and returns one integer. For small changes in the input, the resulting integer should vary greatly. Even though I've taken a number of courses in math, I have not used that knowledge very much and now I need some help... An important property of this function should be that ...

Ruby on Rails workaround for the mySQL max int: 2147483647 ?

I'm trying to use this number: 294670251400 This number will be an attribute in a model that is keeping counter tabs on membership cards. The membership cards have three four digit vanity sets. But when I update_attribute to contain this, the number is reset to mySQL's max int : 2147483647 Anyone have a workaround to this ? ...

Is C# Random Number Generator thread safe?

can anyone tell me if the C# Random.Next() method is thread safe? ...

making numbers to letters (like a cell phone texting) on java??

well this isnt my homework so you can help me out in this, im tryin to solve this for my firm but im really lost in between do i sue sequence or not for example person Input  277-5387 Output  BRSKEUP ...