Skip to content
New issue

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

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

Already on GitHub? # to your account

Newton vs. Kilonewton #9

Open
abolz opened this issue Apr 3, 2021 · 2 comments
Open

Newton vs. Kilonewton #9

abolz opened this issue Apr 3, 2021 · 2 comments

Comments

@abolz
Copy link

abolz commented Apr 3, 2021

The example in the readme states

unlib::newton<double> force = 1._kg * 9.81_m_per_s2;

In the above example, the right-hand side of the assignment operator calculates the force of earth's gravitational pull in kN which is used to initialize a quantity of the unit N. The conversion of the scale (kilo ==> unscaled) necessary for this is done implicitly during the assignment.

Did you intent to use tons instead of kilograms here? Right now the right-hand side already has the unit N and no conversion should be performed.

@gitsbi
Copy link
Owner

gitsbi commented Apr 3, 2021

Thanks, you're right, of course, this doesn't make much sense.

Given that force is still a contentious unit (right now, a newton has the scale 1000/1, which will cause surprising results if you, e.g., get a number scaled to kilo_scaling from a force quantity), I should pick some other unit as an example.

(Since you seem to have just read this for the first time, what unit would you have found helpful for this?)

@abolz
Copy link
Author

abolz commented Apr 5, 2021

The example as such is nice, I think. It's somewhat more interesting than, e.g., 1_cm + 1_m.

I'm not sure what "surprising" results you are referring to, though, since

newton<double> force(1000.0);
assert(1.0 == force.get_scaled<kilo_scaling>());

gives the expected result. I have been playing around with your library a little while right now. And everything has worked just fine so far - without any surprises. Very nice and easy to use library! Thanks!

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

No branches or pull requests

2 participants