Skip to content

unit conversion using the API #733

Answered by hanna-kn
theedge456 asked this question in Q&A
Discussion options

You must be logged in to vote

Prefixes has not been loaded:
c.loadGlobalPrefixes();

loadGlobalDefinitions() is however preferable (a few units depend on variables).

c.convert("10m", "mm") should be c.convert(c.parse("10m"), "mm")

Are there samples of code using the API somewhere ?

No (not that I know of, except the code of the user interfaces). I generally recommend use of Calculator::calculateAndPrint() for simple input and output.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hanna-kn
Comment options

@theedge456
Comment options

@hanna-kn
Comment options

Answer selected by theedge456
@theedge456
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants