-
Notifications
You must be signed in to change notification settings - Fork 99
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
More examples and better doc #97
Comments
Can you give me hint how to store a |
I haven't had a chance to test below, but changing from ISQ!(
uom::si,
i32,
(meter, kilogram, second, kiloampere, kelvin, mole, candela)
); |
Just did a quick test and the above Let me know if you still have questions or additional suggestions for improving documentation. The design tries to answer questions like this. #[macro_use]
extern crate uom;
use uom::si::electric_potential::millivolt;
ISQ!(
uom::si,
i32,
(meter, kilogram, second, kiloampere, kelvin, mole, candela)
);
fn main() {
let l1 = mv::ElectricPotential::new::<millivolt>(1);
let l2 = uom::si::i32::ElectricPotential::new::<millivolt>(1);
println!("{}", l1.value);
println!("{}", l2.value);
} and outputs
|
My problem is that I want to store I was looking for solution that is similar to duration if you know C++11. There you can say that u want to store time in i64 as milliseconds or seconds or hours etc. It use ratio. |
It's look like this will be possible in the future :) |
As you mentioned multiple mod mV { ISQ!(uom::si, i32,(meter, kilogram, second, kiloampere, kelvin, mole, candela));
mod mA { ISQ!(uom::si, i32,(meter, kilogram, second, milliampere, kelvin, mole, candela)); |
Not sure if this is the best place to add this, but since it's a documentation issue and I'm struggling to figure this out... I have a meter/second velocity. How would I convert that to miles/kilometers per hour? I've tried a few things, but none seems to work. The docs include an example of converting velocity to acceleration, but if there's an example of converting the same quantity then I haven't had enough coffee yet. :) Or can I only input a velocity and not convert one? Essentially I want to represent a M/S velocity as a string in KPH/MPH. Whether that means I do a conversion first or if I convert only the string representation is a bit unclear. Thanks for a great library! |
Thanks for the kind words! See #123, specifically the link to the
In your case when you enter a value as
|
Perfectly understandable. I wasn't clear whether the internal
representation was always the same and conversions were only handled
when formatting as a string, which your answer clarifies.
One additional question: is there a convenience/shortcut for truncating
decimals when converting? Right now I'm doing:
```
let distance = format!("{}", distance.into_format_args(meter, Description));
```
This often gives me strings of distances with many decimal points, which
is fine for accuracy but not so great for readouts. :) I'd like either 0
or 1 decimals if at all possible. Do I have to get the units and create
an entirely new length, or is there an easier way?
Thanks again.
|
All of the format specifiers from let distance = format!("{:.0}", distance.into_format_args(meter, Description)); I'll add a note to the other issue to make sure this is explicitly noted. |
Oh, thanks. I'd found format specifiers a while back but had forgotten
about them, and wasn't even sure what to google. Works great!
|
It's would be nice to see more examples (and probably better documented).
For example:
https://github.com/iliekturtles/uom/blob/master/examples/base.rs#L10-L16
could contain copy from doc or just link
I would suggest add
Fahrenheit
orCelcius
example. It would be also nice to see use of i32 instead of float precision numbers.The text was updated successfully, but these errors were encountered: