Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Density Conversions are Incorrect #172

Closed
massonib opened this issue Jun 29, 2016 · 5 comments
Closed

Density Conversions are Incorrect #172

massonib opened this issue Jun 29, 2016 · 5 comments

Comments

@massonib
Copy link
Contributor

I found four errors in the density conversions. Please see below.

public double KilogramsPerCubicCentimeter
{
//Was this // get { return _kilogramsPerCubicMeter_0.00000001; }
get { return kilogramsPerCubicMeter 1e-6; }
}

    public double KilogramsPerCubicMillimeter
    {
        //Was this // get { return _kilogramsPerCubicMeter*0.000000000001; }
        get { return _kilogramsPerCubicMeter*1e-9; }
    }

    public double TonnesPerCubicCentimeter
    {
        //Was this // get { return _kilogramsPerCubicMeter*0.00000000001; }
        get { return _kilogramsPerCubicMeter* 1e-9; }
    }

    public double TonnesPerCubicMillimeter
    {
        //Was this // get { return _kilogramsPerCubicMeter*0.000000000000001; }
        get { return _kilogramsPerCubicMeter* 1e-12; }
    }
@eriove
Copy link
Contributor

eriove commented Jun 29, 2016

Hmm. Looking at the tests and comparing it to Googles unit conversion these seems to be correct.

    protected override double KilogramsPerCubicCentimeterInOneKilogramPerCubicMeter => 1e-6;

    protected override double KilogramsPerCubicMillimeterInOneKilogramPerCubicMeter => 1e-9;

    protected override double TonnesPerCubicCentimeterInOneKilogramPerCubicMeter => 1e-9;

    protected override double TonnesPerCubicMillimeterInOneKilogramPerCubicMeter => 1e-12;

But just looking at this code it seems wrong...

Not sure what I'm missing.

@massonib
Copy link
Contributor Author

Yes, those are correct. The error is in the Density.g.cs file in the properties region.

@massonib
Copy link
Contributor Author

New .json file

{
"Name": "Density",
"BaseUnit": "KilogramPerCubicMeter",
"XmlDoc": "The density, or more precisely, the volumetric mass density, of a substance is its mass per unit volume.",
"XmlDocRemarks": "http://en.wikipedia.org/wiki/Density",
"Units": [
{
"SingularName": "KilogramPerCubicMillimeter",
"PluralName": "KilogramsPerCubicMillimeter",
"FromUnitToBaseFunc": "x_1e+9",
"FromBaseToUnitFunc": "x_1e-9",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "kg/mm³" ]
}
]
},
{
"SingularName": "KilogramPerCubicCentimeter",
"PluralName": "KilogramsPerCubicCentimeter",
"FromUnitToBaseFunc": "x_1e+6",
"FromBaseToUnitFunc": "x_1e-6",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "kg/cm³" ]
}
]
},
{
"SingularName": "KilogramPerCubicMeter",
"PluralName": "KilogramsPerCubicMeter",
"FromUnitToBaseFunc": "x",
"FromBaseToUnitFunc": "x",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "kg/m³" ]
},
{
"Culture": "ru-RU",
"Abbreviations": [ "кг/м³" ]
}
]
},
{
"SingularName": "PoundPerCubicInch",
"PluralName": "PoundsPerCubicInch",
"FromUnitToBaseFunc": "x_27679.904710191",
"FromBaseToUnitFunc": "x/27679.904710191",
"Prefixes": [ "Kilo" ],
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "lb/in³" ],
"AbbreviationsWithPrefixes": [ "kip/in³" ]
}
]
},
{
"SingularName": "PoundPerCubicFoot",
"PluralName": "PoundsPerCubicFoot",
"FromUnitToBaseFunc": "x/0.062427961",
"FromBaseToUnitFunc": "x_0.062427961",
"Prefixes": [ "Kilo" ],
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "lb/ft³" ],
"AbbreviationsWithPrefixes": [ "kip/ft³" ]
}
]
},
{
"SingularName": "TonnePerCubicMillimeter",
"PluralName": "TonnesPerCubicMillimeter",
"FromUnitToBaseFunc": "x_1e+12",
"FromBaseToUnitFunc": "x_1e-12",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "t/mm³" ]
}
]
},
{
"SingularName": "TonnePerCubicCentimeter",
"PluralName": "TonnesPerCubicCentimeter",
"FromUnitToBaseFunc": "x_1e+9",
"FromBaseToUnitFunc": "x_1e-9",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "t/cm³" ]
}
]
},
{
"SingularName": "TonnePerCubicMeter",
"PluralName": "TonnesPerCubicMeter",
"FromUnitToBaseFunc": "x_1000",
"FromBaseToUnitFunc": "x_0.001",
"Localization": [
{
"Culture": "en-US",
"Abbreviations": [ "t/m³" ]
}
]
}
]
}

@massonib
Copy link
Contributor Author

Created pull request with fix.

@angularsen
Copy link
Owner

Fixed in #173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants