Page 1 of 1

[not-a-bug] CDbl() and dividing process

Posted: Tue May 23, 2017 6:26 am
by Harley
Hello everyone!
Maybe I missed something, but when I try to divide in CDbl() for example 1/4 I ever get 0!
But when I multiply in CDbl() 1*0.25, I get 0.25

About 2 years ago I already had this question, but didn't ask it.
Today, I suffered for two days and don't understand, why it's happens.

Need your answer. With best regards!

Re: CDbl() and dividing process

Posted: Tue May 23, 2017 10:03 am
by Nando
Do you mean CDbl(1/4)?

In this case, 1 and 4 are integers. An integer division tells you how many times the second number fits into the first as a whole. In this case, 4 never fits completely into 1, so you get zero.

The division you are used to uses real numbers. With those, you can represent 1.0/4.0 as 0.25, as they're not limited to whole numbers.

You need to convert at least one of the terms to a double if you want to have the real division.

Re: CDbl() and dividing process

Posted: Tue May 23, 2017 1:28 pm
by Harley
Nando, thank you for ur answer!
I'll try and hope it'll help me and other people, who have discovered this one.