numbers

Changing the sign of a number in PHP?

Hay Guys, I have quick question. I have a few floats: -4.50 +6.25 -8.00 -1.75 How can I change all these to negative floats so they become: -4.50 -6.25 -8.00 -1.75 Also i need a way to do the reverse If the float is a negative, make it a positive. Thanks ...

How can I convert a numerical value to text in JavaScript?

I would like to convert a numerical value to a text string. I am opening several windows with the window.open() command and I would like these windows not to be on top of each other. For that I use the argument "left" and "top" in the windows.open command but these parameters need to be text entities. for (var i = 0; i < final_number; ...

Order sets of numbers for maximum distance

You have (up to 100) distinct sets of (2-4) numbers. The order of the sets or numbers in the sets does not matter. The highest number relates to the number of sets and goes up to 30. Like: {1 2 3 4} {1 2 3 5} {1 2 3} {1 2 4 5} {6 2 4} {6 7 8 9} {6 7 9} {7 8 9} {2 4 8 9} The goal is, to arrange these sets in a particular order, where tw...

How to format a number from 1123456789 to 1,123,456,789 in C?

Hi All, How can I in C language format a number from 1123456789 to 1,123,456,789? I tried using printf("%'10d\n", 1123456789); but that doesn't work. Could you advice anything? The simpler the solution the better. Thanks, goe ...

ORACLE SQL:Get all integers between two numbers

Is there any way to select the numbers (integers) that are included between two numbers with SQL in Oracle; I don't want to create PL/SQL procedure or function. For example I need to get the numbers between 3 and 10. The result will be the values 3,4,5,6,7,8,9,10. Thx. ...

Best way of storing very large number of objects in memory?

Very simple question, what would be your way of storing 100 KB - 2 MB objects in memory? Object is made of 3 doubles and two strings (both mostly under 5 chars long). Would using struct instead of class be any better? EDIT: I don't know why I said double, it is float .. :S ...

Number of Records in Insert Statement (Oracle)

I'd like to report on the number of records inserted in an Oracle insert statement. I'm inserting from a statement, so I could run my select twice and a count, but I'd rather keep it all in a single statement. Is there a way? ...

Why is PHP printing my number in scientific notation, when I specified it as .000021?

In PHP I have the following code: <?PHP $var = .000021; echo $var; ?> the output is 2.1E-5 ! Why? it should print .000021 ...

how to tokenize string to array of int in c?

Anyone got anything about reading a sequential number from text file per line and parsing it to an array in C? What I have in a file: 12 3 45 6 7 8 3 5 6 7 7 0 -1 4 5 What I want in my program: array1[] = {12, 3, 45, 6, 7, 8}; array2[] = {3, 5, 6, 7}; array3[] = {7, 0, -1, 4, 5}; I've been through several ways to read it, but the ...

using sscanf(), read string to array of int?

i have this string: 12 4 the quick 99 -1 fox dog \ what i want in my program: myArray[] = {12, 4, 99, -1}; how i do a multiple number scanning? ...

What is the fastest way to check if two given numbers are coprime?

One way is to calculate their gcd and check if it is 1. Is there some faster way? ...

Generate unique numbers from a finite range for more than one node

I'm not even sure the following is possible, but it never hurts to ask: I have two nodes running the same application. Each machine needs a sequence generator that will give it a number between 0 and 1e6. If a node has used a number, the other node must not use it. The generator should reset every night at midnight. No number should be ...

Java DecimalFormat include all digits to the left

I'm trying to format an arbitrary length decimal so all of the numbers to the left of the decimal point are displayed but a maximum of 2 to the right are displayed (if they are non-zero). How can I specify in a DecimalFormat to display all numbers to the left rather than specifying the number of digits ahead of time? thanks, Jeff ...

How do I sort by value from a second level hash, in Perl?

my $hash_ref = { one => { val => 1, name => 'one' }, three => { val => 3, name => 'three'}, two => { val => 2, name => 'two' }, }; I would like to sort $hash_ref such that a foreach would order them by $hash_ref->{$key}->{'val'} one two three Any suggestions? ...

cProfile and Python: Finding the specific line number that code spends most time on

Hi, I'm using cProfile, pstats and Gprof2dot to profile a rather long python script. The results tell me that the most time is spent calling a method in an object I've defined. However, what I would really like is to know exactly what line number within that function is eating up the time. Any idea's how to get this additional inform...

How can I count runs in R?

In R, what would be the most efficient/simplest way to count runs of identical elements in a sequence? For example, how to count the numbers of consecutive zeros in a sequence of non-negative integers: c(1,0,0,0,1,0,0,0,0,0,2,0,0) should give 3,5,2. Thanks. ...

preg_match_all [200932]

Hello everyone i want to preg_match [200932] this from a string. I tryied some pattern but didnt help, any idea? ...

C++ version of isnormal()

Is there a C++ version of the isnormal, isnan and so C functions? I know I can use the C functions from C++, but I'm always interested to know if there are some C++-only alternatives. ...

Array with 500 numbers to make quick toplist template

I need to make an array in php that will output an html table so I can grab the source. ##id:1## ##site:1## ##id:2## ##site:2## etc. 500 times over. ...

How to calculate "modular multiplicative inverse" when the denominator is not co-prime with m?

I need to calculate (a/b) mod m where a and b are very large numbers. What I am trying to do is to calculate (a mod m) * (x mod m), where x is the modular inverse of b. I tried using Extended Euclidean algorithm, but what to do when b and m are not co-prime? It is specifically mentioned that b and m need to be co-prime. I tried using ...