Power operator gives incorrect result

Just starting out? Need help? Post your questions and find answers here.
craig7
User
User
Posts: 35
Joined: Thu Sep 23, 2021 2:49 pm

Power operator gives incorrect result

Post by craig7 »

The below should return 1/4 or 0.25 but instead returns 0.

a = Pow(2.0,-2.0)
Debug a

// Moved from "Bugs - Windows" to "Coding Questions" (Kiffi)
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Power operator gives incorrect result

Post by Mijikai »

Define a as float or double:

Code: Select all

EnableExplicit

Global a.f

a = Pow(2.0,-2.0)
Debug a

End
craig7
User
User
Posts: 35
Joined: Thu Sep 23, 2021 2:49 pm

Re: Power operator gives incorrect result

Post by craig7 »

Mijikai wrote: Fri Sep 24, 2021 11:16 pm Define a as float or double:

Code: Select all

EnableExplicit

Global a.f

a = Pow(2.0,-2.0)
Debug a

End
Ok great thanks
Post Reply