Replies: 1 comment 8 replies
-
Hi, this is a possibility cloneAs(n, u) = unit(n, string(u));
A = unit(100, 'm') # 100 m
cloneAs(2, A) # 2 m |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Suppose you are given a Unit value, and you don't know what units it is in, but you just want to create a different quantity in the same units. Is there a way to do it with just mathjs library functions/in the MaJE (MAthJs Expressions) parser? Diving into the internal structure of Unit in JavaScript, I think the following JavaScript function works, but it seems to break encapsulation. The basic difficulty is that I can't seem to find a function that returns the "valueless unit-only" part of a Unit value.
Any guidance would be welcome, or should I file an issue to add a method like
u.unitPart()
oru.valuelessUnit()
or something like that?Beta Was this translation helpful? Give feedback.
All reactions