numbers

number formatting

I have a simple question how can i show the number 12045678 as 12,045,678 i.e automatically show in american format in jython so 12345 should be 12,345 and 1234567890 should be 1,234,567,890 and so on. Thanks everyone for your help. ...

How can I compare mtimes returned by Perl's stat?

Hello. I found some sample scripts "stat" usage below. $source_mtime = (stat($source_file))[9]; $dest_file_mtime = (stat($dest_file))[9]; $script_mtime = (stat($this_file))[9]; if (-e $dest_xml_file) { if ($dest_file_mtime gt $source_mtime) // gt used { printf "No $this_file Scan Needed\n"; exit(0); } ...

Would you use num%2 or num&1 to check if a number is even?

Well, there are at least two low-level ways of determining whether a given number is even or not: 1. if (num%2 == 0) { /* even */ } 2. if ((num&1) == 0) { /* even */ } I consider the second option to be far more elegant and meaningful, and that's the one I usually use. But it is not only a matter of taste; The actual performance ma...

Convert A to 1 B to 2 ... Z to 26 and then AA to 27 AB to 28 ...

Does any one have algorithm or logic to Convert A to 1 ,B to 2, ... ,Z to 26 and then ,AA to 27, AB to 28 etc. ...

Java - computing large mathematical expressions

Hello all, Im facing a scenario where in ill have to compute some huge math expressions. The expressions in themselves are simple, ie have just the conventional BODMAS fundamental but the numbers that occur as operands are very large, to the tune of 1000 digit numbers. I do know of the BigInteger class of the java.math module but am loo...

Calculate Ratio between 3 numbers with C#

How-to Calculate Ratio between 3 numbers with C# I've 3 collections of doubles. These will be displayed as curves in a single chart. Curve 1 : 1.5,1.6,1.7,1.8,1.9 Curve 2 : 3.5,3.6,3.7,3.8,3.9 Curve 3 : 5.5,5.6,5.7,5.8,5.9 Numbers range between these 3 curves are too different to be displayed correctly in the chart. So i want to "al...

php read start from zero number case

Hi All, May you can help me... many years ago my friend gave me php script code presented below, now i want to change it can read numbering start from zero existing just possible read 1:1, 10:200 etc.. but i want to make also possible read from 01:01, 0000002:0120 etc... function is_valid_number($sesuatu) { if(preg_match("/^([0-9]+)$...

Why don't numbers support .dup?

>> a = 5 => 5 >> b = "hello, world!" => "hello, world!" >> b.dup => "hello, world!" >> a.dup TypeError: can't dup Fixnum from (irb):4:in `dup' from (irb):4 I understand that Ruby will make a copy every time you assign an integer to a new variable, but why does Numeric#dup raise an error? Wouldn't this break abstraction, since ...

WPF: Format Value in XAML with Decimal Seperator?

I have a little problem formatting double values in my XAML code. double price = 10300.455; This number should be displayed as 10,300.45 on US systems and as 10.300,45 on german systems. So far I managed to limit the numbers with the following Binding="{Binding price, StringFormat=F2}" But the result is 10300.45 and that is not wh...

printing out prime numbers from array

I'd like to print out all prime numbers from an array with method. I can do it with one int but don't know how to return certain numbers from array. Thanks for help! public static boolean isPrime(int [] tab) { boolean prime = true; for (int i = 3; i <= Math.sqrt(tab[i]); i += 2) if (tab[i] % i == 0) { ...

Extreme big/small number programming.

I am trying to do some extreme precise maths calculation of very big/small number. The very big number may have 10 - 50 digits and the very small number may have 10 - 50 decimal places. Can C++ do this? If not is there any other programming language that can handle this kind of number? ...

How to change 1,300.00 to 1300,00

In my PHP outputs, number shows 1,234.56 How can I change this to 1234,56 or 1.234,56? What is the American way and European way? Does php work with American way? ...

Add comma to numbers every three digits using jQuery

jQuery plugin to add comma separating numbers into three digits without white spaces and if total digits are under three, then no comma added. Ex. 2984 => 2,984 and 297312984 => 297,312,984 and 298 => 298 $('span.rawNums').digits(); Thanks. ...

how do you fix the clients outgoing port number using php?

Hi there, I'm using php (the sockets extension) to handle sending and receiving xml files. I'd like to be able to fix the outgoing clients port number as the server has a set amount of incoming connections. I find that each time the php script is run it creates a new port number. The client side script I have so far is this:- send_me...

Javascript Error Line Numbers

I have a jsp with lots of javascript code. Whenever there is a javascript error on the page, shown in the status bar of the IE browser, the line number reported to contain the error, does not match with the line number that actually contains the error. I am doing a right click>view source to find the line number reported. But that line d...

C - Check if a value is a number?

How can I check if an integer initialized from function scanf is a number? ...in the simpler way possible thanks :) ...

Generate random number in JavaScript

I need an 2d array [9,16] with 144 numbers from 1->36 in random order (so each number is repeated 4 times). I'm new at JS so can you give a hand, please. Thanks you. ...

sql like operator to get the numbers only

This is I think a simple problem but not getting the solution yet. I would like to get the valid numbers only from a column as explained here. Lets say we have a varchar column with following values ABC Italy Apple 234.62 2:234:43:22 France 6435.23 2 Lions Here the problem is to select numbers only select * from tbl where answer li...

Hex combination of binary flags

Which of the following give back 63 as long (in Java) and how? 0x0 0x1 0x2 0x4 0x8 0x10 0x20 I'm working with NetworkManager API flags if that helps. I'm getting 63 from one of the operations but don't know how should I match the return value to the description. Thanks ...

How do I query on a number in Zend Lucene?

How can I create a Query to search for a number? $query->addTerm(new Zend_Search_Lucene_Index_Term('1', 'id'), null); $query->addTerm(new Zend_Search_Lucene_Index_Term('frank', 'name'), null); $queryP = Zend_Search_Lucene_Search_QueryParser::parse($query); $hits = $ix->find($queryP); echo $queryP; Returns; ...