Float -> Double conversion bug ?
Dear all, If I try to put a float into a double variable the last bits of the precision are total garbage ! If I try to put the float 0.3 into the a double the result is 0.3001192092896 !!! This could be a 'feature' but it renders java (or at least jdk1.2) completely useless for numerics ! Has anyone seen this behaviour below is the small program I used to test it, we first discovered this in a jpython program so hence the cross post to the jpython group. public class Main { public static void main(String args[]) { float a = 3.3f; double b = 3.3d; System.out.println("flt (ToIntBits) = "+Float.floatToIntBits(a)); System.out.println("flt (ToLongBits) = "+Double.doubleToLongBits(a)); System.out.println("dbl (ToLongBits) = "+Double.doubleToLongBits(b)); } } For jpython this means that it is not possible to return a float array from java to jpython session, since it is always converted to double !! I modified the PyFloat.py file in such a way that the contructor for the PyFloat(float) uses the Float.toString() and then the Double.parse(string) to put the proper value in the private attribute value; It was also It is also necesary to modify the Py.java2py in the Py.py file, this function transforms a java array into a Python array. It seems that this code make no difference between a double and a float array, it always uses the double contructor from the PyFloat class so I modified that. I agree it is not very nice but at least it works. public PyFloat(float v) { super(__class__); // Nasty Float _tmp = new Float(v); value = Double.parseDouble(_tmp.toString()); //this((double)v); ** Original code } snip function top if (o instanceof Number) { if (o instanceof Double ) { return new PyFloat(((Number)o).doubleValue()); } else if(o instanceof Float) { return new PyFloat(((Float)o).floatValue()); } snip function end Last question, It seems that if I create and later print an array (say something like : array([0.3, 0.4], 'f')) it first allocates PyFloat variables for 0.3 and 0.4, that it allocates the array BUT then it, when I want to print it, it again allocates two PyFloats to print it (in the __repr__() fucntion in PyArray, or actually in the get(int i) method which calls the Java method Array::get(Object, int)). Q: Why does it allocate twice ? Kind regards, Niels Hilbrink -- Stehlin Merazzi Research sa. tel : +41 32 345 2123 - direct http://www.smr.ch +41 79 607 1014 - mobile Rue Dufour 109b +41 32 345 2120 - fax CH-2500 Bienne 4, Switzerland S/MIME Cryptographic Signature
Re: Float -> Double conversion bug ?
"Burkhart,Kelly" wrote: > > > -Original Message- > > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > > Sent: Friday, September 24, 1999 6:58 AM > > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > > Subject: Float -> Double conversion bug ? > > > > > > Dear all, > > > > If I try to put a float into a double variable the last bits of the > > precision are total garbage ! If I try to put the float 0.3 into the a > > double the result is 0.3001192092896 !!! This could be a 'feature' > > but it renders java (or at least jdk1.2) completely useless > > for numerics > > ! > > This most likely has nothing to do with the Java implementation, but of the > floating point characteristics of the underlying machine. If you set a > double (in C) to 0.3, it's value is not necessarily 0.3 but something very > very close: well yes that is what I would expect, only number ^2 could be represented properly, but what I think happens is that the 'new' double is not properly initialized, ie all bytes are not set to '0'. Apparently the exponent part is transferred correctly, but the mantissa part is not, hence the error in the mantissa. But what I would like to know is if other people experience the same, how does a JVM under windows behave. - Niels -- Stehlin Merazzi Research sa. tel : +41 32 345 2123 - direct http://2159224323 +41 79 607 1014 - mobile Rue Dufour 109b +41 32 345 2120 - fax CH-2500 Bienne 4, Switzerland S/MIME Cryptographic Signature
Java3D and the tnt2
Hi, I was wondering if you still have the problem you mentioned in the bug-list of the Java Linux group since I do. > FYI: J3D doesn't run, at least no in accel. mode, with a TNT2 chip, > it bang out with an error: > Exception in thread "main" java.lang.UnsatisfiedLinkError: > /usr/local/jdk1.2/jre/lib/i386/libJ3D.so: > /usr/local/jdk1.2/jre/lib/i386/libJ3D.so: undefined symbol: glTexImage3DEXT All applications (ie, the mesa demos) run perfectly except the J3D. My solution,em is but I haven't tried yet, was to recompile the Mesa library, the problem, in my opinion, is that the looked for function cannot be found in the Mesa lib but in the glx.so lib which, supposedly, is loaded when the X-server starts up. To the group: Has anyone solved this problem Gr. Niels -- Stehlin Merazzi Research sa. tel : +41 32 345 2123 - direct http://2159224323 +41 79 607 1014 - mobile Rue Dufour 109b +41 32 345 2120 - fax CH-2500 Bienne 4, Switzerland S/MIME Cryptographic Signature
Drag & Drop
Dear all, I have been fiddling unsuccessfully with the Drag and Drop (dnd) features in Java. So far I have been able to do nothing since the only demo application I have (http://java.miningco.com/library/weekly/aa011299.htm if you are interested) does not run. I get an InvalidDnDOperationException exception with the message : " The operation requested cannot be performed by the DnD system since it is not in the appropriate state " I was wondering if anybody has managed to get dnd running and if so if she or he could enlighten me and the rest of the Java Linux community the the way to do it? If not : has anybody managed to get the click and selected mechanism with X to cooperate with Java LINUX ? Kind regards, Niels Hilbrink -- Stehlin Merazzi Research sa. tel : +41 32 345 2123 - direct http://www.smr.ch +41 79 607 1014 - mobile Rue Dufour 109b +41 32 345 2120 - fax CH-2500 Bienne 4, Switzerland +41 91 994 2128 - private -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Cannot compile Magician/Tree/JoGL etc. with JDK1.2pre
Dear all, This is NOT a post containing whining lines of text complaining that J3D does not exist for JDK1.2 ... I tried to use of of the above mentioned OpenGL bindings to no avail, all failed. Some *(Tree and JoGL) during the compilation phase (jni is completely different in JDK1.2) the other with a "UnsatisfiedLinkError" from /usr/lib/jdk1.2/jre/lib/rt.jar ... For some funny reason it cannot find the shared library although the location is in the LD_LIBRARY_PATH (and in /etc/ld.so.conf) Q: did anybody manage to get OpenGL running under JDK1.2 (for LINUX) ? Kind regards, Niels Hilbrink -- Stehlin Merazzi Research sa. tel : +41 32 345 2123 - direct http://www.smr.ch +41 79 607 1014 - mobile Rue Dufour 109b +41 32 345 2120 - fax CH-2500 Bienne 4, Switzerland +41 91 994 2128 - private -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Re: Cannot compile Magician/Tree/JoGL etc. with JDK1.2pre
"A.J. Rossini" wrote: > NH> Q: did anybody manage to get OpenGL running under JDK1.2 (for > NH> LINUX) ? > > I got JOGL compiled. havn't quite got the classpath setup, though :-( > (got errors, saying the OGL not found when trying to run the tests). Really with JDK1.2 prev1 ? Great news, I have some questions though Q1) Did it compiler straight 'out of the box' or did you have to make alterations to the Makefile (notably which includ directories to include ? Q2) Did you manage to do any tests as far as speed is concerned Kind regards, Niels Hilbrink -- Stehlin Merazzi Research sa. tel : +41 32 345 2123 - direct http://www.smr.ch +41 79 607 1014 - mobile Rue Dufour 109b +41 32 345 2120 - fax CH-2500 Bienne 4, Switzerland +41 91 994 2128 - private -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
Magician => works on JDK1.2 but ...
Dear all, I posted a message yesterday saying that I couldn't get Magician to work ... wel now it works, after loading the shared library my self. I get the following error (in a pop-up menu "Magician Error"): Library load[0]: ml I look to me that it tries to load the libmlxsm.so shared lib but that the name some how gets mangeled. This happens in the "internal" routines from magician, to which I don't have any access. Q: Does anybody have a solution for this, just in case people from arcana are monitoring this group : Please fix this) Gr. Niels -- Stehlin Merazzi Research sa. tel : +41 32 345 2123 - direct http://www.smr.ch +41 79 607 1014 - mobile Rue Dufour 109b +41 32 345 2120 - fax CH-2500 Bienne 4, Switzerland -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]