"#const=1/4" equates to 0 - miscalc but no compilererror

Just starting out? Need help? Post your questions and find answers here.
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

"#const=1/4" equates to 0 - miscalc but no compilererror

Post by Keya »

maybe there should be either a compiler alert for this or a correct calculation (it caused a bug which took me a while to track down):

Code: Select all

#const = 1/4   ;i was assuming this would convert to 0.25 as the compiler didnt complain
Debug Str(#const)   ;= 0
Debug StrF(#const)  ;= 0
tested in Windows PB 5.44
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: "#const=1/4" equates to 0 - miscalc but no compilererror

Post by wilbert »

Looks fine to me as you are specifying integers for the constant.
If you want floats, you can use floats for the constant.

Code: Select all

#const = 1.0/4.0
Windows (x64)
Raspberry Pi OS (Arm64)
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: "#const=1/4" equates to 0 - miscalc but no compilererror

Post by Josh »

It's enough, if one part is a float
sorry for my bad english
Post Reply