Qalculate / libqalculate

Qalculate! library and CLI
https://qalculate.github.io/
GNU General Public License v2.0
1.8k stars 145 forks source link

`1G` returns '0.06674 mm^3/(kg*s^2)' instead of '1000000000' #706

Open ittayd opened 3 days ago

ittayd commented 3 days ago

What do I need to change so that 'G' is interpreted as 10^9? Note that 1giga works.

Related, how can I make 'K' (and not 'k') be interpreted as kilo ?

hanna-kn commented 3 days ago

G is the symbol for the gravitational constant, and K for the unit Kelvin. Prefixes should ideally not be used without a unit and uppercase K is not a symbol for kilo.

The easiest way to change the interpretation of K and G is to replace the unit and constant with custom variables (e.g. using commands variable K 1000 and variable G 10^9).

ittayd commented 3 days ago

Thanks. If I try this I either get "Do you want to overwrite it" question every time I start or need to save it in ~/.local/share/qalculate/definitions so that it then applies to all sessions. Is there a flag to say something like 'temporary' so that the overwrite prompt isn't used? I tried set save definitions no and set save mode no.

hanna-kn commented 3 days ago

The simplest variant is K=1000.

ittayd commented 3 days ago

Is there a way to make it silent, so 1000 and 1000000000 are not output ?

ittayd commented 2 days ago

I tried passing in 'K=1000;1' as an argument and get [1000 1] as the output. I want to get only 1

hanna-kn commented 1 day ago

I tried passing in 'K=1000;1' as an argument and get [1000 1] as the output. I want to get only 1

Semicolon is used as separator for function argument, vector elements, and matrix rows (in the two first cases this is primarily relevant when comma is used as decimal or digit group separator).

If the only purpose of ";1" is to output "1" instead of "1000", save(1000, K)^0, or similar, should work.

I've now made some changes (see commit 6b60732) which should make the variable command more suited for this case.

Depending on how you use qalc, use of the clear command after the variable definitions might be an alternative.