Problems with Division / Probleme mit Division

Posted By: HoopyDerFrood

Problems with Division / Probleme mit Division - 02/11/09 19:06

Hi,
I've recognized a strange behavior connected with the Division operator. I've a test variable (var) that I screen with two decimals.
And when I set this variable to the result of a calulation it always is an integer when I use the "/" operator. Can anyone check if he recognizes a similar behavior? I want to check this carefully before I call it a "bug".

test1 = 4/3; -> Screens "1.00"
test1 = 5/2; -> Screens "2.00"
test1 = 5*0.5 -> Screens "2.50" (so decimals work theoretical)

Hallo,
mir ist ein seltsames Verhalten in zusammenhang mit Divisionen aufgefallen. Ich habe eine Testvariable (var) die ich mit 2 Nachkommastellen Anzeige. Nur wenn ich diese Variable auf das Ergebnis einer Division setzte bekomme ich immer eine ganze Zahl. (siehe oben). Könnte das mal Irgendjemand überprüfen, ob er ein ähnliches Verhalten feststellt? Ich möchte es gründlich überprüfen befor ich es "bug" nenne.
Posted By: Quad

Re: Problems with Division / Probleme mit Division - 02/11/09 19:24

4.0/3.0 or 4/3.0 will work i guess.

when you divide ints it results in int.
Posted By: HoopyDerFrood

Re: Problems with Division / Probleme mit Division - 02/11/09 20:07

Thank you, it works.
So it isn't a bug but a case for "blame the manual".

I've another question. I have an extern functtion coded in C++, compiled with VC++.

Code:
DLLFUNC double CamGetDLLVersion(void)
{
	return 1.43;
}


But when I screen the result of calling the function it differs a litte bit to 1.43. For example 1.41 is the result.
© 2024 lite-C Forums