Issue Details (XML | Word | Printable)

Key: JSCIENCE-135
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: jscience-issues
Reporter: rcasha
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
jscience

Mathematical error in calculating compound values

Created: 15/Apr/09 07:54 AM   Updated: 31/Jan/11 02:48 AM
Component/s: www
Affects Version/s: current
Fix Version/s: Version 6.0

Time Tracking:
Not Specified

Environment:

Operating System: All
Platform: All


Issuezilla Id: 135
Tags:
Participants: jscience-issues and rcasha


 Description  « Hide

The technique for converting decimal degrees into degrees-minutes-seconds does
not work correctly (gives wrong figures).

eg: 35.857497 should convert to 35°51'27, but instead produces 35°50'26"

This might be some rounding error.

Sample Code:
------------------------------------------------------
package test;

import java.math.BigDecimal;
import javax.measure.DecimalMeasure;
import javax.measure.quantity.Angle;
import javax.measure.unit.NonSI;
import javax.measure.unit.Unit;
import static javax.measure.unit.NonSI.*;

public class TestDMS {

public static final Unit<Angle> DMS =
DEGREE_ANGLE.compound(MINUTE_ANGLE).compound(SECOND_ANGLE);

public static void main(String[] args) { DecimalMeasure<Angle> v1 = new DecimalMeasure<Angle>(new BigDecimal("35.857497"), NonSI.DEGREE_ANGLE); System.out.println(v1); DecimalMeasure<Angle> v2 = v1.to(DMS); System.out.println("actual = "+v2); System.out.println("expected = 35°51'26.99\""); }

}
------------------------------------------------------
I'm re-posting this here since it's the first bug in project JSR-275 and I don't
know if there's anyone watching that one.

https://jsr-275.dev.java.net/issues/show_bug.cgi?id=1



There are no comments yet on this issue.