toSI() on a scalar
See original GitHub issueIs there a way to make toSI() work on a scalar? The use case is when I want to display the result of an expression in SI unit if it has units. Like this:
- math.evaluate(‘1 cm’).toSI() --> 0.01 m
- math.evaluete(‘2cm / 1cm’).toSI() --> 2
Or, is there a function that works like hasunit
in the following example?
if (hasunit(var)) {
print(var.toSI());
}
else {
print(var);
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
NumberQuantity (Units of Measurement Reference Implementation ...
Returns the scalar quantity for the specified short stated in the specified unit. Parameters: value - the quantity value. unit - the measurement...
Read more >Succinctly implementing newtypes for multiple scalar units
It must not be possible to do erroneous calculations because values are in different units. The amount of code duplication must be limited....
Read more >massless scalar particles: Topics by Science.gov
In this paper, we investigate the influences of external massless scalar field to quantum Prisoners' Dilemma (QPD) game. We firstly derive the master ......
Read more >Search for third-generation scalar leptoquarks decaying to a ...
Abstract A search for pair production of heavy scalar lep- toquarks (LQs), each decaying into a top quark and a τ lep- ton,...
Read more >LegalizerHelper Class Reference - LLVM
Legalize a vector instruction by splitting into multiple components, each acting on the same scalar type as the original but with fewer elements....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I also wasn’t confortable with extending JS
Number
, so I assume that I can close the PR 😇 One dirty code snippet:👍
Thanks @rnd-debug for all your inputs.