From 6cf9c535413e8e3e7d79c919c8f7af74b0278c11 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Fri, 12 Jul 2024 23:55:07 +0200 Subject: [PATCH 1/3] fix: Fix area unit values Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- .../data/converter/collections/Area.kt | 107 +++++++++++++++--- 1 file changed, 94 insertions(+), 13 deletions(-) diff --git a/data/converter/src/main/java/app/myzel394/numberhub/data/converter/collections/Area.kt b/data/converter/src/main/java/app/myzel394/numberhub/data/converter/collections/Area.kt index 44be791c..2d17b54c 100644 --- a/data/converter/src/main/java/app/myzel394/numberhub/data/converter/collections/Area.kt +++ b/data/converter/src/main/java/app/myzel394/numberhub/data/converter/collections/Area.kt @@ -27,19 +27,100 @@ import java.math.BigDecimal internal val areaCollection: List by lazy { listOf( - NormalUnit(UnitID.cent, BigDecimal("6083246572000000000000000000000000"), UnitGroup.AREA, R.string.unit_cent, R.string.unit_cent_short), - NormalUnit(UnitID.acre, BigDecimal("60832465720000000000000000000000"), UnitGroup.AREA, R.string.unit_acre, R.string.unit_acre_short), - NormalUnit(UnitID.hectare, BigDecimal("150320296400000000000000000000000"), UnitGroup.AREA, R.string.unit_hectare, R.string.unit_hectare_short ), - NormalUnit(UnitID.square_foot, BigDecimal("1396521251000000000000000000"), UnitGroup.AREA, R.string.unit_square_foot, R.string.unit_square_foot_short), - NormalUnit(UnitID.square_mile, BigDecimal("38932778060000000000000000000000000"), UnitGroup.AREA, R.string.unit_square_mile, R.string.unit_square_mile_short), - NormalUnit(UnitID.square_yard, BigDecimal("12568691260000000000000000000"), UnitGroup.AREA, R.string.unit_square_yard, R.string.unit_square_yard_short), - NormalUnit(UnitID.square_inch, BigDecimal("9698064247000000000000000"), UnitGroup.AREA, R.string.unit_square_inch, R.string.unit_square_inch_short), - NormalUnit(UnitID.square_micrometer, BigDecimal("15032029640000000"), UnitGroup.AREA, R.string.unit_square_micrometer, R.string.unit_square_micrometer_short), - NormalUnit(UnitID.square_millimeter, BigDecimal("15032029640000000000000"), UnitGroup.AREA, R.string.unit_square_millimeter, R.string.unit_square_millimeter_short), - NormalUnit(UnitID.square_centimeter, BigDecimal("1503202964000000000000000"), UnitGroup.AREA, R.string.unit_square_centimeter, R.string.unit_square_centimeter_short), - NormalUnit(UnitID.square_decimeter, BigDecimal("150320296400000000000000000"), UnitGroup.AREA, R.string.unit_square_decimeter, R.string.unit_square_decimeter_short), - NormalUnit(UnitID.square_meter, BigDecimal("15032029640000000000000000000"), UnitGroup.AREA, R.string.unit_square_meter, R.string.unit_square_meter_short), - NormalUnit(UnitID.square_kilometer, BigDecimal("15032029640000000000000000000000000"), UnitGroup.AREA, R.string.unit_square_kilometer, R.string.unit_square_kilometer_short), + // https://www.gowebtool.com/unit-conversion/area/convert.php?from=electron_cross_section&to=acre + NormalUnit( + UnitID.acre, + BigDecimal("60832465720659000000000000000000"), + UnitGroup.AREA, + R.string.unit_acre, + R.string.unit_acre_short, + ), + // https://www.gowebtool.com/unit-conversion/area/convert.php?from=electron_cross_section&to=cent + NormalUnit( + UnitID.cent, + BigDecimal("608324656845820000000000000000"), + UnitGroup.AREA, + R.string.unit_cent, + R.string.unit_cent_short, + ), + NormalUnit( + UnitID.hectare, + BigDecimal("150320296474920000000000000000000"), + UnitGroup.AREA, + R.string.unit_hectare, + R.string.unit_hectare_short, + ), + NormalUnit( + UnitID.square_foot, + BigDecimal("1396526843537100000000000000"), + UnitGroup.AREA, + R.string.unit_square_foot, + R.string.unit_square_foot_short, + ), + // https://www.gowebtool.com/unit-conversion/area/convert.php?from=electron_cross_section&to=square_mile_survey_us_statute + NormalUnit( + UnitID.square_mile, + BigDecimal("38932934238959000000000000000000000"), + UnitGroup.AREA, + R.string.unit_square_mile, + R.string.unit_square_mile_short, + ), + NormalUnit( + UnitID.square_yard, + BigDecimal("12568691264599000000000000000"), + UnitGroup.AREA, + R.string.unit_square_yard, + R.string.unit_square_yard_short, + ), + NormalUnit( + UnitID.square_inch, + BigDecimal("9698064247375700000000000"), + UnitGroup.AREA, + R.string.unit_square_inch, + R.string.unit_square_inch_short, + ), + NormalUnit( + UnitID.square_micrometer, + BigDecimal("15032029647492000"), + UnitGroup.AREA, + R.string.unit_square_micrometer, + R.string.unit_square_micrometer_short, + ), + NormalUnit( + UnitID.square_millimeter, + BigDecimal("15032029647492000000000"), + UnitGroup.AREA, + R.string.unit_square_millimeter, + R.string.unit_square_millimeter_short, + ), + NormalUnit( + UnitID.square_centimeter, + BigDecimal("1503202964749200000000000"), + UnitGroup.AREA, + R.string.unit_square_centimeter, + R.string.unit_square_centimeter_short, + ), + NormalUnit( + UnitID.square_decimeter, + BigDecimal("150320296474920000000000000"), + UnitGroup.AREA, + R.string.unit_square_decimeter, + R.string.unit_square_decimeter_short, + ), + NormalUnit( + UnitID.square_meter, + BigDecimal("15032029647492000000000000000"), + UnitGroup.AREA, + R.string.unit_square_meter, + R.string.unit_square_meter_short, + ), + NormalUnit( + UnitID.square_kilometer, + BigDecimal("15032029647492000000000000000000000"), + UnitGroup.AREA, + R.string.unit_square_kilometer, + R.string.unit_square_kilometer_short, + ), NormalUnit(UnitID.electron_cross_section, BigDecimal("1"), UnitGroup.AREA, R.string.unit_electron_cross_section, R.string.unit_electron_cross_section_short), ) } From 68c17d1d973c17db4dfcfb42c39731b3ae8f7157 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Fri, 12 Jul 2024 23:55:32 +0200 Subject: [PATCH 2/3] tests: Add more tests to area unit tests Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- .../myzel394/numberhub/data/converter/AllUnitsTest.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/data/converter/src/test/java/app/myzel394/numberhub/data/converter/AllUnitsTest.kt b/data/converter/src/test/java/app/myzel394/numberhub/data/converter/AllUnitsTest.kt index 575a3b2f..39bebf18 100644 --- a/data/converter/src/test/java/app/myzel394/numberhub/data/converter/AllUnitsTest.kt +++ b/data/converter/src/test/java/app/myzel394/numberhub/data/converter/AllUnitsTest.kt @@ -119,12 +119,19 @@ class AllUnitsTest { @Test fun testArea() = testWithUnits { - cent.checkWith(acre, "75.9", "7590") + cent.checkWith(acre, "75.9", "0.759") + cent.checkWith(square_meter, "1", "40.469") acre.checkWith(square_kilometer, "75.9", "0.30716") + acre.checkWith(square_yard, "1", "4840") + acre.checkWith(square_meter, "1", "4046.856") + acre.checkWith(cent, "1", "4046.856") + hectare.checkWith(acre, "1", "2.471"); + hectare.checkWith(acre, "1", "2.471"); hectare.checkWith(square_foot, "75.9", "8169808.00585") square_foot.checkWith(square_decimeter, "75.9", "705.13407") square_mile.checkWith(square_foot, "75.9", "2115970560.8762") square_yard.checkWith(square_foot, "75.9", "683.1") + square_yard.checkWith(square_foot, "1", "9") square_inch.checkWith(square_foot, "75.9", "0.52708") square_micrometer.checkWith(square_millimeter, "75.9", "0.00008") square_millimeter.checkWith(square_centimeter, "75.9", "0.759") From 0a021975fc980e974b71a99927690275b1cbbc84 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sat, 13 Jul 2024 11:44:36 +0200 Subject: [PATCH 3/3] fix: Fix unit values Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com> --- .../data/converter/collections/Area.kt | 4 ++-- .../numberhub/data/converter/AllUnitsTest.kt | 17 ++++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/data/converter/src/main/java/app/myzel394/numberhub/data/converter/collections/Area.kt b/data/converter/src/main/java/app/myzel394/numberhub/data/converter/collections/Area.kt index 2d17b54c..59f716dd 100644 --- a/data/converter/src/main/java/app/myzel394/numberhub/data/converter/collections/Area.kt +++ b/data/converter/src/main/java/app/myzel394/numberhub/data/converter/collections/Area.kt @@ -52,7 +52,7 @@ internal val areaCollection: List by lazy { ), NormalUnit( UnitID.square_foot, - BigDecimal("1396526843537100000000000000"), + BigDecimal("1396521251622100000000000000"), UnitGroup.AREA, R.string.unit_square_foot, R.string.unit_square_foot_short, @@ -60,7 +60,7 @@ internal val areaCollection: List by lazy { // https://www.gowebtool.com/unit-conversion/area/convert.php?from=electron_cross_section&to=square_mile_survey_us_statute NormalUnit( UnitID.square_mile, - BigDecimal("38932934238959000000000000000000000"), + BigDecimal("38932778061222000000000000000000000"), UnitGroup.AREA, R.string.unit_square_mile, R.string.unit_square_mile_short, diff --git a/data/converter/src/test/java/app/myzel394/numberhub/data/converter/AllUnitsTest.kt b/data/converter/src/test/java/app/myzel394/numberhub/data/converter/AllUnitsTest.kt index 39bebf18..66806e11 100644 --- a/data/converter/src/test/java/app/myzel394/numberhub/data/converter/AllUnitsTest.kt +++ b/data/converter/src/test/java/app/myzel394/numberhub/data/converter/AllUnitsTest.kt @@ -120,16 +120,18 @@ class AllUnitsTest { @Test fun testArea() = testWithUnits { cent.checkWith(acre, "75.9", "0.759") - cent.checkWith(square_meter, "1", "40.469") + cent.checkWith(square_meter, "1", "40.46856") acre.checkWith(square_kilometer, "75.9", "0.30716") acre.checkWith(square_yard, "1", "4840") - acre.checkWith(square_meter, "1", "4046.856") - acre.checkWith(cent, "1", "4046.856") - hectare.checkWith(acre, "1", "2.471"); - hectare.checkWith(acre, "1", "2.471"); - hectare.checkWith(square_foot, "75.9", "8169808.00585") + acre.checkWith(square_meter, "1", "4046.85642") + acre.checkWith(cent, "1", "100") + hectare.checkWith(acre, "1", "2.47105"); + hectare.checkWith(square_foot, "1", "107639.10417") + hectare.checkWith(square_foot, "75.9", "8169808.00628") square_foot.checkWith(square_decimeter, "75.9", "705.13407") - square_mile.checkWith(square_foot, "75.9", "2115970560.8762") + square_mile.checkWith(square_foot, "1", "27878400") + // Probably floating point error + square_mile.checkWith(square_foot, "75.9", "2115970560.00002") square_yard.checkWith(square_foot, "75.9", "683.1") square_yard.checkWith(square_foot, "1", "9") square_inch.checkWith(square_foot, "75.9", "0.52708") @@ -140,6 +142,7 @@ class AllUnitsTest { square_meter.checkWith(acre, "75.9", "0.01876") square_kilometer.checkWith(hectare, "75.9", "7590") electron_cross_section.checkWith(square_micrometer, "75.9", "0.000000000000005") + square_decimeter.checkWith(acre, "123.456", "0.00031") } @Test