Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 168041 Details for
Bug 310397
Draw2D Euclidean Geometry (Ray, Straight) should support double precision.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to restore 1.4 backwards compatibility
310397.txt (text/plain), 2.75 KB, created by
Alexander Nyßen
on 2010-05-11 17:10:08 EDT
(
hide
)
Description:
Patch to restore 1.4 backwards compatibility
Filename:
MIME Type:
Creator:
Alexander Nyßen
Created:
2010-05-11 17:10:08 EDT
Size:
2.75 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.draw2d >Index: src/org/eclipse/draw2d/geometry/Vector.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/geometry/Vector.java,v >retrieving revision 1.4 >diff -u -r1.4 Vector.java >--- src/org/eclipse/draw2d/geometry/Vector.java 30 Apr 2010 22:38:16 -0000 1.4 >+++ src/org/eclipse/draw2d/geometry/Vector.java 11 May 2010 21:07:49 -0000 >@@ -14,8 +14,6 @@ > package org.eclipse.draw2d.geometry; > > import java.math.BigDecimal; >-import java.math.MathContext; >-import java.math.RoundingMode; > > /** > * Represents a vector within 2-dimensional Euclidean space. >@@ -324,38 +322,42 @@ > * converting to 16 digits precision (and scale), so there are no undesired > * rounding effects. > */ >- private static final MathContext CONTEXT = MathContext.DECIMAL64; >- private static final RoundingMode ROUNDING = CONTEXT.getRoundingMode(); >- private static final int SCALE = CONTEXT.getPrecision(); >+ private static final int ROUNDING = BigDecimal.ROUND_HALF_EVEN; >+ private static final int SCALE = 16; > > private static final double preciseAdd(double d1, double d2) { >- return BigDecimal.valueOf(d1).add(BigDecimal.valueOf(d2), CONTEXT) >+ return doubleToBigDecimal(d1).add(doubleToBigDecimal(d2)) > .setScale(SCALE, ROUNDING).doubleValue(); > } > > private static final double preciseSubtract(double d1, double d2) { >- return BigDecimal.valueOf(d1).subtract(BigDecimal.valueOf(d2), CONTEXT) >+ return doubleToBigDecimal(d1).subtract(doubleToBigDecimal(d2)) > .setScale(SCALE, ROUNDING).doubleValue(); > } > > private static final double preciseMultiply(double d1, double d2) { >- return BigDecimal.valueOf(d1).multiply(BigDecimal.valueOf(d2), CONTEXT) >+ return doubleToBigDecimal(d1).multiply(doubleToBigDecimal(d2)) > .setScale(SCALE, ROUNDING).doubleValue(); > } > > private static final double preciseDivide(double d1, double d2) { >- return BigDecimal.valueOf(d1).divide(BigDecimal.valueOf(d2), CONTEXT) >+ return doubleToBigDecimal(d1).divide(doubleToBigDecimal(d2)) > .setScale(SCALE, ROUNDING).doubleValue(); > } > > private static final double preciseNegate(double d) { >- return BigDecimal.valueOf(d).negate(CONTEXT).setScale(SCALE, ROUNDING) >+ return doubleToBigDecimal(d).negate().setScale(SCALE, ROUNDING) > .doubleValue(); > } > > private static final double preciseAbs(double d) { >- return BigDecimal.valueOf(d).abs(CONTEXT).setScale(SCALE, ROUNDING) >+ return doubleToBigDecimal(d).abs().setScale(SCALE, ROUNDING) > .doubleValue(); > } > >+ private static final BigDecimal doubleToBigDecimal(double d){ >+ // May not use BigDecimal.valueOf due to J2SE-1.4 backwards compatibility >+ return new BigDecimal(Double.toString(d)); >+ } >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 310397
:
166050
|
168041
|
168047