Page 1 of 1

Division?

Posted: February 5th, 2020, 9:39 am
by Anne
This is a question I never thought I would ask in this forum, but how do we divide numbers?

I tried the following:

errmsg("%d", 1/3);

and the result was 0, but I want 0.33333

The manual claims that / is the division operator working on numeric expressions and also that a numeric variable is an integer or decimal number significant to 15 digits, so it should work, shouldn't it?

Anne

Re: Division?

Posted: February 5th, 2020, 10:14 am
by josh
The division is fine but I think you need %f instead of %d in the errmsg

Re: Division?

Posted: February 5th, 2020, 10:23 am
by Anne
(I knew it: How utterly embarrasing.. :oops: )

Thanks