nan

What is the rationale for all comparisons returning false for IEEE754 NaN values?

Why do comparisons of NaN values behave differently from all other values? That is, all comparisons with the operators ==, <=, >=, <, > where one or both values is NaN returns false, contrary to the behaviour of all other values. I suppose this simplifies numerical computations in some way, but I couldn't find an explicitly stated reaso...

Checking NAN or -NAN In Access 2007

We are in the process of migrating Access 2007 to SQL 2005. We have a table with about 200 columns of float fields. Some of the fields have values of positive infinity or negative infinity ( 1.#INF or -1.#INF when viewed in Access ). Is there a way to clean this day or identify this data so we can report back to the owners the bad r...

MATLAB: Find all NaN elements inside an Array

Is there a command in MATLAB that allows me to find all NaN (Not-a-Number) elements inside an array? ...

Blank when NaN in jqGrid cells.

How to set blank instead of NaN in jqGrid cells ? Using formatter ? Is there an example? ...

Why do MSTests Assert.AreEqual(1.0, double.NaN, 0.0) pass?

Short question, why do Assert.AreEqual(1.0, double.NaN, 0.0) pass when Assert.AreEqual(1.0, double.NaN) do not? Is it an error in MSTest or am I missing something here? Best regards, Egil. Update: Should probably add, that the reason behind my question is, that I have a bunch of unit tests that unfortunately passed due to the result o...

NaN problem in Java

I am converting four bytes to float and I'm getting NaN as a result, but I want the value 0.0. What am I doing wrong? This is my code: public class abc { public static void main(String[] args) { int[] arry = { 255, 255, 255, 255 }; int num = ((arry[0] << 24) & 0xFF000000) | ((arry[1] << 16) & 0xFF0000) | ((...

Break on NaNs or infs

Hello all, It is often hard to find the origin of a NaN, since it can happen at any step of a computation and propagate itself. So is it possible to make a C++ program halt when a computation returns NaN or inf? The best in my opinion would be to have a crash with a nice error message: Foo: NaN encoutered at Foo.c:624 Is something li...

Java MDSJ produces NaN

Anyone have any experience with MDSJ? The following input produces only NaN results and I can't figure out why. The documentation is pretty sparse. import mdsj.Data; import mdsj.MDSJ; public class MDSJDemo { public static void main(String[] args) { double[][] input = { {78.0, 60....

In Javascript, how to avoid NaN when adding arrays

I'm trying to add the values of two arrays in javascript eg. [1,2,1] + [3,2,3,4] The answer should be 4,4,4,4 but I'm either getting 4,4,4 or 4,4,4,NaN if I change the 1st array length to 4. I know a 4th number needs to be in the 1st array, but i can't figure out how to tell javascript to make it 0 rather then undefined if there i...

matrix addition skipping NaN values

I would like to do element wise addition over matrices while skipping NaN values. MATLAB and Octave have nansum, but it does column wise addition within a matrix. Let: a = NaN * zeros(3) b = ones(3) I want: c = nan+(a, b) and c = b and: d = nan+(a,a) and d = a ...

JavaScript is a NaN, but I know it's not?

I have the following two functions... function splitTitleString(titleText) { var titleText = titleText; var temp = new Array(); temp = titleText.split(' - '); var now = new Date().getTime(); var warningExpResp = 7200000; var expRespDateTimeTicks = 0; var slaDateTimeTicks = 0; if(temp[0].length > 0) ...

Java maths - testing for NaN

I would like to have some kind of project-wide fail fast mechanism (maybe a RuntimeException) for any code that causes assignment of NaN. In my project NaN is never a valid value. I realise I could add asserts (using isNaN) or other tests throughout but I want to know if there is a more elegant way. ...

What are the other NaN values?

The documentation for java.lang.Double.NaN says that it is A constant holding a Not-a-Number (NaN) value of type double. It is equivalent to the value returned by Double.longBitsToDouble(0x7ff8000000000000L). This seems to imply there are others. If so, how do I get hold of them, and can this be done portably? To be clear, I woul...

What is the fastest way to initialize all elements in an array to NaN?

In C# .NET, what is the fastest way to initialize an array of doubles to NaN? Here is how I am presently initializing an array with many elements. int length = array.Length; for(int i = 0; i < length; i++) { array[i] = double.NaN; } Is there a faster way? ...

Recursive harmonic function returns NaN

Hi, I have written the following sample code to find the harmonic value of N. (1+1/2+1/3+...1/N). Read the comments in the code written in BOLD and help me to find why is this happening. #include <stdio.h> float harmonic(float n, float har) { if(n==0) { return 0; } if(n==1) { printf("%f\n", har+1.0f);***/...

Sum two graphs, when the second RRD file is started only now

I don't know how to explain my problem.... but I have two RRD files: a.rrd b.rrd I'm trying to sum both of the files and STACK them up in the graph. like: my $bla = RRDs::graph "-", "--title","Test", "--imgformat=PNG", "--width=680", "--height=200", "DEF:Default0_=a.rrd:default:AVERAGE", "DEF:Real0_=a.rrd:re...

Javas Math.sin() produces NaN all the time

Forgive me if this is a dumb beginners problem, but I really don't get it. I have a member variable declared like so: public Double Value; When I assign 3.14159265 to Value and try to compute the sine of it, this happens: system.out.println(Value.toString()); //outputs 3.14159265 Value = Math.sin(Value); system.out.println(Value.toS...

double.NaN Equality in MS Test

Why am I getting this result? [TestMethod] public void nan_test() { Assert.AreEqual(1, double.NaN, 1E-1); <-- Passes Assert.AreEqual(1, double.NaN); <-- Fails } What difference does the delta have in asserting NaN equals a number? Surely it should always return false. I am aware of IsNaN, but that's not useful here (see ...

How do I force 0.0/0.0 to return zero instead of NaN in MIPSPro C compiler?

As the question states, I am using the MIPSPRo C compiler, and I have an operation that will return NaN for some data sets where both the numerator and denom are zero. How do I keep this from happening? ...

ActionScript black color value is NaN

i'm trying to determine if a color has been supplied as an optional argument to a function. in order to determine this, i'm simply writing if(color){...} and supplying NaN if i don't want there to be a color. however, it seems that the color black (0x000000) also equates to NaN. how can i determine if a supplied color number argument ...