Raised This Month: $51 Target: $400
 12% 

Solved %f and division by 4096


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 05-29-2021 , 05:52   %f and division by 4096
Reply With Quote #1

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

example of output

Last edited by kww; 05-29-2021 at 13:24.
kww is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-29-2021 , 06:44   Re: %f and division by 4096
Reply With Quote #2

Because dataA and dataB are integer variables and not declared as float.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 05-29-2021 , 07:10   Re: %f and division by 4096
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
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

Last edited by kww; 05-29-2021 at 07:10.
kww is offline
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 05-29-2021 , 07:26   Re: %f and division by 4096
Reply With Quote #4

http://www.amxmodx.org/api/float/float
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 05-29-2021 , 09:04   Re: %f and division by 4096
Reply With Quote #5

new Float:fValue
read_data(arg_num, fValue)
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-29-2021 , 09:11   Re: %f and division by 4096
Reply With Quote #6

Or if you are really reading integers then read them just as you do now and convert only when you do the division.
__________________
HamletEagle is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-29-2021 , 11:41   Re: %f and division by 4096
Reply With Quote #7

And use 4096.0 instead of 4096: fValue / 4096.0. While not required, it's cleaner IMO.
__________________

Last edited by Bugsy; 05-29-2021 at 11:44.
Bugsy is offline
kww
Senior Member
Join Date: Feb 2021
Location: Russia
Old 05-29-2021 , 13:23   Re: %f and division by 4096
Reply With Quote #8

Thank you all very much!
kww is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:01.


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