jscience
  1. jscience
  2. JSCIENCE-135

Mathematical error in calculating compound values

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: Version 6.0
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      135

      Description

      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

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            jscience-issues
            Reporter:
            rcasha
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: