Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: double to string causes divide by zero!



On Feb 27, 2004, at 12:54 PM, FSato wrote:

A portion of operations on double (and/or long) variables should be synchronized.

This is a vague statement and can easily mislead, as have several statement so far in this thread by others (some IMHO doing more "harm" then good).

You should synchronize access when multiple threads are likely attempting to _modify_ or _modify and read_ the _same_ variable, in general, regardless of what primitive type is involved (using volatile may be sufficient depending on how things are used, considering performance issues).

In this case the top level source is providing a double value that is only read from so that leaves the compiler expanded string concatenation use of StringBuffer append(double) and its use of FloatingDecimal.dtoa as a possible source of a concurrency issue.

So to know what is gong on look at the source for the classes involved, they are provided by Sun after all (standard language classes). The source will tell you how things are handled. Greg Guerin, took some of his own time, to do this for the folks and it does not look like a threading issue exists directly in the code pathway involved because of the use of proper synchronization when needed, use of non-shared variables or those only read from.

I have not reviewed the source myself I however believe that Greg's is likely correct in the above.

As Greg notes it looks to be a JVM or JITC issue... report it [1] and include your test case code.

-Shawn

[1] - <http://bugreporter.apple.com>
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: double to string causes divide by zero! (From: FSato <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.