numbers

We know log_add, but how to do log_subtract?

Multiplying two numbers in log space means adding them: log_multiply(x, y) = log( exp(x) * exp(y) ) = x + y Adding two numbers in log space means you do a special log-add operation: log_add(x, y) = log( exp(x) + exp(y) ) which is implemented in the following code, in a way that doesn't require us to take the two ...

How to test random numbers?

i have written in matlab, a program, which is supossed to generate random numbers between 0 and 1. i have test it only with the runstest in matlab, and te result is that the sequence is random. i have seen the histograms too, and they have a beta distribution. i want to test this rng whith other test, such as diehard, ent, or nist, but i...

Round Off decimal values in C#

how do i round off decimal values ? Example : decimal Value = " 19500.98" i need to display this value to textbox with rounded off like " 19501 " if decimal value = " 19500.43" then value = " 19500 " ...

The file 'C:\....\.....\.....\bin\debug\128849991926295643' already exists

Hi, I'm using Visual C#2008 Express Edition and an Express SQL database. Every time I build my solution, I get an error like the one above. Obviously the file name changes. A new file is also created every time I hit a debug point. I have a stored proc that gets every row from a database table, it gets these rows every time the main for...

Getting a integer value from a textbox, how to check if it's NaN or null etc?

I am pulling a value via JavaScript from a textbox. If the textbox is empty, it returns NaN. I want to return an empty string if it's null, empty,etc. What check do I do? if(NAN = tb.value) ? ...

How do I format number locale-specific in Perl?

I need to format numbers in my web application depending on user's chosen language, e.g. 1234.56 = "1.234,56" in German. Stuff like sprintf is currently out of question, since they depend on LC_NUMERIC (which is sensible for desktop applications IMHO) and I'd have to generate every locale on the server, which is a no-go. I would prefer u...

How do I use JavaScript for number formatting?

Hi, I want to use JavaScript to restrict input on a text box to currency number formatting. For example: <input type="text" value="2,500.00" name="rate" /> As given above, the text box should accept only numbers, commas and a period. But, after the period it should accept two digits after numbers. How do I accomplish this? Please ...

PHP Currency Regular Expression

Hi All I am trying to find a piece of regex to match a currency value. I would like to match only numbers and 1 decimal point ie Allowed 10 100 100.00 Not Allowed Alpha Characters 100,00 +/- 100 I have search and tried quite a few without any luck. Hope you can advise ...

How to convert strings numbers to integers in a list?

I have a list say: ['batting average', '306', 'ERA', '1710'] How can I convert the intended numbers without touching the strings? Thank you for the help. ...

Select Something + An arbitrary Number in Mysql

I have a situation where I need to do something like select 2, id from users; I think that would work at least with Oracle but it doesn't work in Mysql. Any ideas? ...

string format with %g in C

How do I create a string so that it formats floating point numbers to have no trailing decimal point or digits when it is an integer, but to NOT switch to scientific notation for larger numbers? When I do: float myFloat= 15.6f; float myInt = 5.0f; float myLarge = 7000000.0f; sprintf(out, "my float is %g", myFloat); ...

Formatting a (large) number "12345" to "12,345"

Say I have a large number (integer or float) like 12345 and I want it to look like 12,345. How would I accomplish that? I'm trying to do this for an iPhone app, so something in Objective-C or C would be nice. ...

How do I convert a decimal number to REAL10 in MASM assembly?

Right now I convert the string containing the decimal number to an integer (ignoring the radix point for now), load it into ST(0), and divide by the correct power of ten to account for the radix point. This seems round about, and requires I have a look up table for some of the powers of 10. Is there a better way to do this? ...

How do I determine the maximum and minimum value for an Oracle NUMBER column?

Is there a simple formula for determining the maximum and minimum values for an Oracle NUMBER column with (p, s)? ...

How to limit the maximum value of a numeric field in a Django model?

Django has various numeric fields available for use in models, e.g. DecimalField and PositiveIntegerField. Although the former can be restricted to the number of decimal places stored and the overall number of characters stored, is there any way to restrict it to storing only numbers within a certain range, e.g. 0.0-5.0 ? Failing that, ...

Large Numbers in Java

How would i go about doing calculations with extremely large numbers in Java? i have tried long but that maxes out at 9223372036854775807, and when using an integer it does not save enough digits and therefore is not accurate enough for what i need. Is there anyway around this? ...

Numbers Comparison - Python Bug?

Hello, Deep inside my code, in a nested if inside a nested for inside a class method, I'm comparing a certain index value to the length of a certain list, to validate I can access that index. The code looks something like that: if t.index_value < len(work_list): ... do stuff ... else: ... print some error ... For clarificati...

Setting Property for Percentage Format ASP.Net

Applogies for what I have no doubt is a noob question. I display several percentage values in a Grid View in ASP.Net I want to be able to set the NumberFormatInfo.PercentPositivePattern Property which I think I have to bring in a Globals "property" to be able to adjust? from its Default 0 to 1 This is the property I need to adjust h...

Bash script, Illegal number: 08

I'm running a pretty simple bash script in ubuntu but have come up with a problem. If needed I'll post the whole script, but I've narrowed down the problem. Basically, I want to run some code every 15 seconds, so I started with this: time=`date +%S` time2=$((time%15)) if [ $time2 -eq 0 ] then etc, etc, etc.... The problem comes up...

How can I convert a binary number into a string character using Perl script?

Hi, How can I convert a binary number into a string character using Perl script? thanks in advance. ...