AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved %f and division by 4096 (https://forums.alliedmods.net/showthread.php?t=332727)

kww 05-29-2021 05:52

%f and division by 4096
 
Hi guys! why %f gives me 0.000000 when i'm dividing some numbers?
code

example of output

Natsheh 05-29-2021 06:44

Re: %f and division by 4096
 
Because dataA and dataB are integer variables and not declared as float.

kww 05-29-2021 07:10

Re: %f and division by 4096
 
Quote:

Originally Posted by Natsheh (Post 2748158)
Because dataA and dataB are integer variables and not declared as float.

if i declaring this variables as float (new Float:dataA) then compiler says: tag mismatch
how can i convert integer to float

Shadows Adi 05-29-2021 07:26

Re: %f and division by 4096
 
http://www.amxmodx.org/api/float/float

Natsheh 05-29-2021 09:04

Re: %f and division by 4096
 
new Float:fValue
read_data(arg_num, fValue)

HamletEagle 05-29-2021 09:11

Re: %f and division by 4096
 
Or if you are really reading integers then read them just as you do now and convert only when you do the division.

Bugsy 05-29-2021 11:41

Re: %f and division by 4096
 
And use 4096.0 instead of 4096: fValue / 4096.0. While not required, it's cleaner IMO.

kww 05-29-2021 13:23

Re: %f and division by 4096
 
Thank you all very much!


All times are GMT -4. The time now is 02:35.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.