What is Double.NaN
hi i want to know what is Double.NaN ?
the SUN doc says, "....... A constant holding a Not-a-Number (NaN) value of type double...." then what is the content of Double.NaN ?
suppose i am writing Double a = new Double(Double.NaN); what is the content of a ?
i want an example of Double.NaN ? can you give one example of what does that mean ?
It is a value that is the result of certain arithmetic
operations, such as multiplying infinity by zero or
dividing infinity by infinity. ok...i am not doing any illegal arithmetic operation below. how about the code ?
public class Base
public static void main(String args[])
Double a = new Double(Double.NaN);
Double b = new Double(Double.NaN);
System.out.println(a.NaN); // trying to see what is the default of Nan field
System.out.println(b.NaN); // trying to see what is the default of Nan field
if( Double.NaN == Double.NaN ) // line 1
System.out.println("True");
else
System.out.println("False");
if( a.equals(b) ) // line 2
System.out.println("True");
else
System.out.println("False");
i am getting output
NaN
NaN
False
True
Press any key to continue...
that means default of NaN field is a NaN. look //line 1 . if both of them gets default value NaN then why not the output is true ?
and also look at line 2 . both of them have contents NaN. why why not the output is true here also.
so , the output should have been
NaN
NaN
true
true
but it is not.
where is the mistake ?
Similar Messages
-
What is Double.NaN for?
I'm trying to understand what is Double.NaN for. I did understand the use od Double.POSITIVE_INFINITY and Double.NEGATIVE_INFINITY. I did try
double value = Double.parseDouble("123ws34");
and then
if (value == Double.NaN)NaN (not a number) is returned by various methods when the result from a function is undefined. You can use this fact to code a reasonable action when the program does something silly - like dividing zero by zero.
-
Strange behaviour of Double.NaN
I have a question, which is purely for my own interest as I've read the documentation and know that when checking for a doulbe being "Not a Number" you should use Double.isNan() and not double== Double.NaN.
However,
I'm confused as to how this works. If you look inside the Double Class, you will see that Double.NaN is defined as a static final - i.e. a constant.
Now the following code:
if(Double.NaN == Double.NaN) will always return false. But should the compiler optimise this and realise the result is true? After all its just a static final like any other constant.
Secondly, the inplementation of Double.isNan(double d) is as follows:
static public boolean isNaN(double v) {
return (v != v);
}Again, when this was compiled, shouldn't the compiler just optimize it and realise the result is always false?
If anyone can shed light on this I would be most interested!
Thankserm...wrong again.
consider the following code:
public static final double a = 1.0;
public static final double NaN = 0.0d/0;
if(a!=a) System.out.println("This is wierd");
if(NaN!=NaN) System.out.println("This is wierder");
No, not wrong again.
Your question was specific to Double.NaN, and like you said yourself, and like this code demonstrates, Double.NaN != Double.NaN
The result is that only the second print statement
appears. How my question is, they are both just
constants, not evaluated dynamically at runtime but
fixed at compile time. So how does it work?I fail to see the problem. Yes, Double.NaN is a compile-time constant. So what? I fail to see how that should make any difference.
The == operator always gives false when one or both of its arguments is Double.NaN. What does it matter how it works - the actual implementation of it will be different from one compiler and JVM to another - you shouldn't really care how it works - you just need to know that it is defined to work that way. -
Do you know , what is Double level domain in ABAP ?
1.
Do you know , what is Double level domain in ABAP ?
2. Have you heard of any concept called " loggi " or simillar ...?Hey Fren,
In the DDIC we have a concept called as dual-level domain.
Let us have an example to get it cleared...
Imagine you need to create Transparent Table with the following fields....
01. Booking_ID
02. Name_of_Person
03. Arrival_Time
04. Arrival_Date
05. Departure_Date
06. Departure_Time
07. Country_From
08. City_From
09. Country_to
10. City_To
11. Price
Now, in this case you need to create 11 domains if there was not a dual-level concept..
But the dual-level concept helps us in having a better maintainability.
In the above example,
|i--------Fields -------|-----DataElements-----|-----Domains-------i|
|i-----------------------------------------------------------------i|
| Arrival_Time | ZTime_1 }_______> Z_Time
| Departure_Time | ZTime_2 }
|--------------------------------------------------------------------|
| Arrival_Date | Zdate_1 }_______> Z_Date
| Departure_Date | Zdate_2 }
|--------------------------------------------------------------------|
| Country_From | ZCountry_1 }_______> Z_Country
| Country_To | ZCountry_2 }
|--------------------------------------------------------------------|
| City_From | ZCity_1 }_______> Z_City
| City_To | ZCity_2 }
|--------------------------------------------------------------------|
| Price | ZPrice }-----> ZPrice
The Fields having Similar Technical Attributes are associated to the same Domain but due to the different Semantic Meaning the Fields are Associated with different Data Elements...
Thus it helps us in Maintaining the Data Elements Centrally ....i.e at the Domain level.....
Hence Dual-Level Domain Concept........
To have some more Information on Domains,
Please refer [http://help.sap.com/saphelp_nw70/helpdata/EN/cf/21ea0b446011d189700000e8322d00/frameset.htm]
Inspire if this helped,
Warm Regards,
Abhi... -
This class is supposed to check how many real numbers are being sent to All and depending on that perform further operations with those numbers.
It works just fine if all four number are present, but if one number is missing (i.e. fourth number in n2 in main), when it goes to All the first condition is ALWAYS true, even though it says if the number is not NaN it just skips it and goes to AllN with four numbers. Am I not using Double.NaN right?
public class Numbers {
public double num1 = Double.NaN, num2 = Double.NaN;
public double num3 = Double.NaN, num4 = Double.NaN;
public double first = Double.NaN, second = Double.NaN;
public double third = Double.NaN, fourth = Double.NaN;
public String snum0;
// accessor methhods
public void setNum1 (double value) {
num1 = value;
public void setNum2 (double value) {
num2 = value;
public void setNum3 (double value) {
num3 = value;
public void setNum4 (double value) {
num4 = value;
public double getNum1 () {
return num1;
public double getNum2 () {
return num2;
public double getNum3 () {
return num3;
public double getNum4 () {
return num4;
public double getFirst () {
if (first != Double.NaN)
return first;
else
return Double.NaN;
public double getSecond () {
if (second != Double.NaN)
return second;
else
return Double.NaN;
public double getThird () {
if (third != Double.NaN)
return third;
else
return Double.NaN;
public double getFourth () {
if (fourth != Double.NaN)
return fourth;
else
return Double.NaN;
public void All (Numbers s) {
if (s.num4 != Double.NaN &&
s.num3 != Double.NaN &&
s.num2 != Double.NaN &&
s.num1 != Double.NaN)
AllN(s.num1, s.num2, s.num3, s.num4);
else if (s.num4 == Double.NaN &&
s.num3 != Double.NaN &&
s.num2 != Double.NaN &&
s.num1 != Double.NaN)
AllN(s.num1, s.num2, s.num3);
else if (num4 == Double.NaN &&
num3 == Double.NaN &&
num2 != Double.NaN &&
num1 != Double.NaN)
AllN(num1, num2);
else if (s.getNum4() == Double.NaN &&
s.getNum3() == Double.NaN &&
s.getNum2() == Double.NaN &&
s.getNum1() != Double.NaN)
AllN(num1);
else if (s.getNum4() == Double.NaN &&
s.getNum3() == Double.NaN &&
s.getNum2() == Double.NaN &&
s.getNum1() == Double.NaN)
AllN();
}// end SortAll
public void AllN() {
snum0 = "There are no numbers to sort";
public static void main (String args[]) {
Sort n1 = new Sort();
n1.setNum1(13);
n1.setNum2(14);
n1.setNum3(15);
n1.setNum4(16);
n1.SortAll(n1);
Sort n2 = new Sort();
n2.setNum1(57);
n2.setNum2(34);
n2.setNum3(50);
n2.SortAll(n2);
System.out.println(n1.getSecond());
System.out.println(n2.getFirst());
} // End Maindouble v = 5.0;
if (v == v) {
System.out.println("v is a number: "+v);
} else { // (v != v)
System.out.println("v is not a number: "+v);
// or
if (Double.isNaN(v)) {
System.out.println("v is not a number: "+v);
} else {
System.out.println("v is a number: "+v);
} -
What is double byte support for Materials?
We recently upgraded to ECC5 Unicode form our earleir no unicode 46C.
In this regard:
How do we do a double byte language set up for Material master?
What is meant by double byte support in the first place?
Pl advise.
- VenIf the system is Unicode no specific settings are necessary, you can enter the language code in the material text of any language and enter the text. If all people have the right fonts installed it will be displayed without problems.
Markus -
What would cause double letters with a single key stroke while adding information to Calendar? Version: 10.10.2 wireless keyboard 27" iMac 3.4 GHz i5. Have restarted computer, have closed/opened Calendar, switched on/off keyboard and taken batteries out/in of keyboard. The problem only happens while typing in Calendar.
Not sure if I am accidentally hitting an unknown key to cause the problem or if it is a Calendar issue.........paulTry changing System Preferences/Keyboard/Keyboard/Key Repeat to a slower setting. Test.
-
It seems that there is a bug in the way the virtual machine compares floating point NaN's. My understanding of the spec is that dcmpg and fcmpg should return +1 if one of the stack elements are NaN. As far as I can see -1 is returned (which is what dcmpl and fcmpl does).
I have tried 1.4.2 on win2000 and kvm cldc1.1 on win2000.
Any comments?Interesting, but if you look at:
http://java.sun.com/docs/books/vmspec/2nd-edition/html/
nstructions2.doc3.html
the spec for dcmp says that it should push 1 to the
stack, which it does not. The VM and language spec
seems to say different things. And the VM is following
the language spec and not its own spec.
I don't understand what you are talking about. The code that you posted is java - not byte codes. The java code should return nothing which it does.
But looking a the bytes codes for the above (using 1.4.0_01-b03) I get the following partial byte code listing for the first expression ...
14 dcmpg
15 ifge 26
18 getstatic #15 <Field java.io.PrintStream out>
21 ldc #117 <String "one">
23 invokevirtual #23 <Method void println(java.lang.String)>From the VM spec for ifge...
<if>ge succeeds if and only if value >= 0
And your code doesn't print 'one'. That means the branch is being taken.
That means only one of the following is true.
1. There is a '1' (or some positive value on the stack.)
2. The documentation for ifge is wrong.
So are you also stating that the documentation for ifge is wrong?
If not then you need to provide exact information on how you determine that there is a '-1' on the stack instead of a '1'. And perhaps provide the real context that demonstrates this. -
What causes double letters skips and wrong letters when typing
Os 10.9.5
Tried a new keyboard and still get skips, double letters, and wrong letters non adjacent to the intended key.Boot into Safe Mode, Mac OS X: Starting up in Safe Mode, and see if the problem persists there. If not then reboot normally and try again.
-
What is wrong with this?
I am trying to make a program that does simple binary operations, it is not working. I think I am missing some constructors, but don't know what they are. Any help would be appreciated.
//Expression.java
package Math;
public abstract class Expression {
public abstract String toString();
public abstract double evaluateMe();
public static void main(String args[]){
Sum s1 = new Sum(new Number(7.123456789), new Number(11.3344));
Sum s2 = new Sum(s1, new Multiply(s1, new Number(3)));
System.out.println("s2 = " + s2 + " with value " + s2.evaluateMe());
//Number.java
package Math;
public class Number extends Expression {
double num;
public String toString() {
return String.valueOf(num);
//return num.decimalFormat()
//return the number but to 2nd place
public double evaluateMe(){
return num;
//Sum.java
package Math;
public class Sum extends Expression {
Expression left;
Expression right;
public String toString(){
return "(" + left.toString() + ")" + "+" + "(" + right.toString() + ")";
public double evaluateMe(){
return left.evaluateMe() + right.evaluateMe();
//Product.java
package Math;
public class Product extends Expression {
Expression left;
Expression right;
public String toString(){
return "(" + left.toString() + ")" + "*" + "(" + right.toString() + ")";
public double evaluateMe(){
return left.evaluateMe() * right.evaluateMe();
}Once again ThanksHERE YOU GO!
YOU OWE ME BIG!
public class MathMachine{
public static void main(String[] args){
new MathMachine();
public MathMachine(){
Expression e1 = new Expression(Operation.ADD, 5, 3);
Expression e2 = new Expression(Operation.MULTIPLY, new Number(2), e1);
System.out.println("Expression: " + e2.toString() + " = " + e2.evaluate().getValue());
// EVALUATOR
public interface Evaluator{
public String toString();
public Number evaluate();
// NUMBER
public class Number implements Evaluator{
public Number(double number){ this.number = number; }
public String toString(){ return "" + number; }
public Number evaluate(){ return this; }
public double getValue(){ return number; }
double number;
// EXPRESSION
public class Expression implements Evaluator{
public Expression(int operation, double x, double y){
this.operation = operation;
this.x = new Number(x);
this.y = new Number(y);
public Expression(int operation, Evaluator x, Evaluator y){
this.operation = operation;
this.x = x;
this.y = y;
public String toString(){
return "(" + x.toString() + Operation.getOperatorString(operation) + y.toString() + ")";
public Number evaluate(){ return new Number(Operation.evaluate(this)); }
int operation;
Evaluator x;
Evaluator y;
// OPERATION
public static class Operation{
static final int ADD = 1;
static final int SUBTRACT = 2;
static final int MULTIPLY = 3;
static final int DIVIDE = 4;
public static String getOperatorString(int operator){
switch(operator){
case ADD: return "+";
case SUBTRACT: return "-";
case MULTIPLY: return "*";
case DIVIDE: return "/";
default: return "error";
public static double evaluate(Expression e){
switch(e.operation){
case ADD: return e.x.evaluate().getValue() + e.y.evaluate().getValue();
case SUBTRACT: return e.x.evaluate().getValue() - e.y.evaluate().getValue();
case MULTIPLY: return e.x.evaluate().getValue() * e.y.evaluate().getValue();
case DIVIDE: return e.x.evaluate().getValue() / e.y.evaluate().getValue();
default: return Double.NaN;
} -
Hi all!
I'd like to know what kind of data Oracle database stores when I insert a NaN value. For example:
Row myRow = viewObject.createRow();
myRow.setAttribute("NumberField1", new oracle.jbo.domain.Number(Double.NaN));
vo.insertRow();
viewObject.insertRow(myRow);
appModule.getDBTransaction.postChanges();
appModule.getDBTransaction.commit();
It's a kind of problematic situation, because any PL/SQL operation on field, like division or multiplication, will generate a loss of service.
Thanks
GleberHi 73012 !!!
Thanks for your response.
Is this a new Oracle10g function? I think this function is not available on Oracle 9.2.0.5.0, is it right?
How can I handle NaN values on Oracle 9.2.0.5.0?
Thank you again!
Gleber -
Can anyone tell me what this is doing
hey this is part of some parser code from an earlier java forum post
http://forum.java.sun.com/thread.jspa?threadID=506162&messageID=2399163#239 9163
i modified the code slightly to work with my program which involves its use in an applet and to solve logical equations. However i'm still uncertain as to what certain sections of the code are doing
i know that this code evaluates the variables within the given equation, begins a for loop that does not exit until i = codeSize which is the length of the given String. However i'm not so certain as to how it achieves this. I'd like to know
private int eval(int variableX, int variableY, int variableZ)
try {
int top = 0;
for (int i = 0; i < codeSize; i++)
if (code[i] >= 0)
stack[top++] = constants[code];
else if (code[i] >= POWER)
int y = stack[--top];
int x = stack[--top];
int ans = (int)Double.NaN;
switch (code[i])
case PLUS: ans = x | y; break;
case MINUS: ans = x & y; break;
case TIMES: ans = x & y; break;
case DIVIDE: ans = x / y; break;
// case POWER: ans = Math.pow(x,y); break;
if (Double.isNaN(ans))
return ans;
stack[top++] = ans;
else if (code[i] == VARIABLEX)
stack[top++] = variableX;
else if (code[i] == VARIABLEY)
stack[top++] = variableY;
else if(code[i] == VARIABLEZ)
stack[top++] = variableZ;
/* else {
double x = stack[--top];
double ans = Double.NaN;
int d;
d = (int) ans;
switch (code[i])
case SIN: ans = Math.sin(x); break;
case COS: ans = Math.cos(x); break;
case TAN: ans = Math.tan(x); break;
case COT: ans = Math.cos(x)/Math.sin(x); break;
case SEC: ans = 1.0/Math.cos(x); break;
case CSC: ans = 1.0/Math.sin(x); break;
case ARCSIN: if (Math.abs(x) <= 1.0) ans = Math.asin(x); break;
case ARCCOS: if (Math.abs(x) <= 1.0) ans = Math.acos(x); break;
case ARCTAN: ans = Math.atan(x); break;
case EXP: ans = Math.exp(x); break;
case LN: if (x > 0.0) ans = Math.log(x); break;
case LOG2: if (x > 0.0) ans = Math.log(x)/Math.log(2); break;
case LOG10: if (x > 0.0) ans = Math.log(x)/Math.log(10); break;
case ABS: ans = Math.abs(x); break;
case SQRT: if (x >= 0.0) ans = Math.sqrt(x); break;
case UNARYMINUS: ans = -x; break;
if (Double.isNaN(ans))
return d;
stack[top++] = d;
catch (Exception e)
double b = Double.NaN;
int i = (int)b;
return i;
} double d2;
if (Double.isInfinite(stack[0]))
d2 = Double.NaN;
int i2 = (int) d2;
return i2;
}else
return stack[0];
any help much appreciated
cheers
podgerWell this is a very basic interpreter. What this piece of code does is:
1) take an opcode from the code array, and retrieves the description for it from the constants array. This description is stored in the stack array.
stack[top++] = constants[code];
2) check what opcode it is
switch (code)
3) "execute" the opcode with simple java math operators.
case PLUS: ans = x | y; break;
case MINUS: ans = x & y; break;
case TIMES: ans = x & y; break;
case DIVIDE: ans = x / y; break;4) store the result of the opcode in the stack array, after the description of the opcode retrieved in step 1)
stack[top++] = ans;There is also some sort of error check in there: initially the result of the opcode is "NaN", (not a number). If the opcode passed to this code is not known, the result is not added to the stack according to this piece of code:
if (Double.isNaN(ans))
return ans; -
Why not Integer.NaN?
Hello
I wonder why Integer does not supply a NaN like Double.NaN. I find the Double.Nan to be very useful.
Regards
JT:) I think what you mean is that integers are
normally only used with the basic arithmetic
operations: +, -, *, and / (I miss having Python's
built-in exponentiation operator). These operations
never return infinity or NaN, with the single notable
exception of division by zero. And dividing by zero
is almost always an accident with integers, and is
easy to check for.Yes, that's what I meant. My post was so dumb even I have to laugh at it. First, I didn't say integers are closed over multiplication, and then I said modulo and remainder like they're two different things. And integers aren't closed under integer division because of 0, as you said.
Floating point numbers, on the other hand, are often
used with transcendental functions and fractional
exponents and things, which frequently result in
infinity or NaN. Moreover, it's important to be able
determine that the result is one of those things, so
we have constants for them. Also, it's often hard to
check these things ahead of time with these
functions.
You dig?
As an aside, I wonder if an operator-overloading
framework could be developed for Java by explicitly
basing the use of operators on interfaces. For
instance, to use the arithmetic operators, you would
implement an interface called Field. To use
the comparison operators, you would implement an
interface called Ordered (which would
basically be identical to the Comparable interface).
You get the idea. The premise would be that it
t would the operators to conform with their standard
mathematical definitions.As someone adamantly opposed to operator overloading in Java, this proposal is ok to me. If you're familiar with the matlab language, operator overloading is done there by defining functions like "plus()", etc... so its sort of similar I think. I think C++ gets difficult because you can overload operators like the function call operator (), and the member of operator(s) which gets confusing really quick. -
Float.NaN doesn't seem to work with appserver7
I am in the process of upgrading an existing application that uses Float.NaN for invalid values when persisting to the database. I am upgrading from just using SQL statements to entity beans for the persistence layer. Is Float.NaN or Double.NaN not supported in EJB2.0 in appserver 7? The error message I get is that it is column 'NaN' does not exist.
Here is the descriptor in ejb-jar:
<entity>
<display-name>Attribute</display-name>
<ejb-name>Attribute</ejb-name>
<local-home>com.dataservices.common.ejb.entity.attribute.AttributeLocalHomeIF</local-home>
<local>com.dataservices.common.ejb.entity.attribute.AttributeLocalIF</local>
<ejb-class>com.dataservices.common.ejb.entity.attribute.AttributeBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>com.dataservices.common.ejb.entity.attribute.AttributeKey</prim-key-class>
<reentrant>False</reentrant>
<abstract-schema-name>Attribute</abstract-schema-name>
<cmp-field>
<field-name>id</field-name>
</cmp-field>
<cmp-field>
<field-name>resultId</field-name>
</cmp-field>
<cmp-field>
<field-name>x</field-name>
</cmp-field>
<cmp-field>
<field-name>y</field-name>
</cmp-field>
<cmp-field>
<field-name>z</field-name>
</cmp-field>
<cmp-field>
<field-name>comments</field-name>
</cmp-field>
<query>
<query-method>
<method-name>find</method-name>
<method-params>
<method-param>int</method-param>
</method-params>
</query-method>
<ejb-ql>SELECT OBJECT (attribute) FROM Attribute AS attribute WHERE attribute.id = ?1</ejb-ql>
</query>
<query>
<query-method>
<method-name>findByIdAndResultId</method-name>
<method-params>
<method-param>int</method-param>
<method-param>int</method-param>
</method-params>
</query-method>
<ejb-ql>SELECT OBJECT (attribute) FROM Attribute AS attribute WHERE attribute.id = ?1 AND attribute.resultId = ?2</ejb-ql>
</query>
<query>
<query-method>
<method-name>findAllByResultId</method-name>
<method-params>
<method-param>int</method-param>
</method-params>
</query-method>
<ejb-ql>SELECT OBJECT (attribute) FROM Attribute AS attribute WHERE attribute.resultId = ?1</ejb-ql>
</query>
</entity>
Here is sun-cmp-mapping:
<entity-mapping>
<ejb-name>Attribute</ejb-name>
<table-name>Attribute</table-name>
<cmp-field-mapping>
<field-name>x</field-name>
<column-name>Attribute.x</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>comments</field-name>
<column-name>Attribute.comments</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>y</field-name>
<column-name>Attribute.y</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>z</field-name>
<column-name>Attribute.z</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>id</field-name>
<column-name>Attribute.id</column-name>
</cmp-field-mapping>
<cmp-field-mapping>
<field-name>resultId</field-name>
<column-name>Attribute.resultId</column-name>
</cmp-field-mapping>
</entity-mapping>
Here is the bean:
package com.dataservices.common.ejb.entity.attribute;
import javax.ejb.*;
* Created Apr 13, 2005 8:05:33 AM
* Code generated by the Sun ONE Studio EJB Builder
* @author mebrewster
public abstract class AttributeBean implements javax.ejb.EntityBean {
private javax.ejb.EntityContext context;
* @see javax.ejb.EntityBean#setEntityContext(javax.ejb.EntityContext)
public void setEntityContext(javax.ejb.EntityContext aContext) {
context=aContext;
* @see javax.ejb.EntityBean#ejbActivate()
public void ejbActivate() {
* @see javax.ejb.EntityBean#ejbPassivate()
public void ejbPassivate() {
* @see javax.ejb.EntityBean#ejbRemove()
public void ejbRemove() {
* @see javax.ejb.EntityBean#unsetEntityContext()
public void unsetEntityContext() {
context=null;
* @see javax.ejb.EntityBean#ejbLoad()
public void ejbLoad() {
* @see javax.ejb.EntityBean#ejbStore()
public void ejbStore() {
public abstract int getId();
public abstract void setId(int id);
public abstract int getResultId();
public abstract void setResultId(int resultId);
public abstract double getX();
public abstract void setX(double x);
public abstract double getY();
public abstract void setY(double y);
public abstract double getZ();
public abstract void setZ(double z);
public abstract java.lang.String getComments();
public abstract void setComments(java.lang.String comments);
public com.dataservices.common.ejb.entity.attribute.AttributeKey ejbCreate(com.dataservices.common.cbo.attribute attribute) throws javax.ejb.CreateException {
setId(attribute.getId());
setResultId(attribute.getResultId());
setX(attribute.getX());
setY(attribute.getY());
setZ(attribute.getZ());
setComments(attribute.getComments());
return null;
public void ejbPostCreate(com.dataservices.common.cbo.Attribute attribute) throws javax.ejb.CreateException {
x, y, z are all floats in the database and in the Attribute object. If I change setX(attribute.getX()); to setX(Float.NaN); (Did this to make sure it wasn't in the code outside the beans)I get the invalid column name in list error message in the servers log file.(It doesn't matter if I change x or y or z, they all do it.)
Thanks for your help! -
NumberFormatException: Infinite or NaN
I do some heavy calculations with lots of variables and formulars. Depending on the values, some other values (results) can get the value "NaN" or Infinite. At the end, I want to store the results in database and convert my doubles to BigDecimal objects. At this point I get such exceptions:
java.lang.NumberFormatException: Infinite or NaN
at java.math.BigDecimal.<init>(BigDecimal.java:274)The only workaround i found so far, is to check each value via
if (value1 == Double.NaN || value1 == Double.POSITIVE_INFINITY || value1 == Double.NEGATIVE_INFINITY) {
value1 = 0.0;
}And i have up to 30 values that can be NaN/Infinity. So, I'm looking for some other solution?Well, I got a shorter form, but I hoped to somehow workaround this NaN/Infinity problem different:
private final double resetNaN(double value) {
double result = value;
if (Double.isNaN(value) || Double.isInfinite(value)) {
result = 0.0;
return result;
}//resetNaN()
Maybe you are looking for
-
How to use a visa gift card in itunes store
Can you use a visa gift card in the itunes store and if so how do you set it up?
-
Hi Folks, I have made a VOFM routine in data tranfer->Sales activities.I have activated the program and also the entry in "Maintain:Data transport sales activities" But still i am getting an error "No frame work was found for the Include RV44A601".I
-
Hello, I'm trying to install Arch x86_64 with the 2012/08 ISO, but every time I try to install the packages, pacman says some of them are "invalid or corrupt (PGP signature)". If I re-download them, some other random packages become corrupt! I have a
-
Asking for passcode when trying to change restrictions on iphone 3gs
In response to a person on here for deleting a gmail account from an iphone 3GS I can not enter the passcode for restrictions? Can anyone assist?
-
Keylistener problem... please help....
Here is a piece of code that was killing me today ... I want to allow the user only to type numbers in the field .. could someone please rewrite the part of the code that is wrong... Thank Youuuuuu In Advance public Ccc(){ NumericKeyHandler keyh = ne