AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [fixed]devide float by float AMXX problems (https://forums.alliedmods.net/showthread.php?t=154126)

Owyn 04-03-2011 06:25

[fixed]devide float by float AMXX problems
 
PHP Code:

new Devident 16
new Devisor 24
new Float:result floatdivfloat(Devident), float(Devisor) ) 

first it was just
PHP Code:

float(Devident) / float(Devisor

but then i thought that floatdiv() might help, but it does calculations exactly the same way.

it devides 16 by 24 and gets 0.761904 while windows calc.exe gets 0,695652

Devident | Devisor |what amxx gets | what calc.exe gets:

17 by 23 = ( 0.809523 ) against 0,73913043478260869565217391304348
11 by 18 = ( 0.647058 ) against 0,61111111111111111111111111111111
11 by 15 = ( 0.785714 ) against 0,73333333333333333333333333333333
11 by 20 = ( 0.578947 ) against 0,55
9 by 16 = ( 0.600000 ) against 0,5625

what and where is wrong and how it can be fixed?

hleV 04-03-2011 10:15

Re: devide float by float AMXX problems
 
Code:
new Float:result = float(Devident / Devisor)
?

Owyn 04-03-2011 12:14

Re: devide float by float AMXX problems
 
Quote:

Originally Posted by hleV (Post 1443785)
Code:
new Float:result = float(Devident / Devisor)

?

won't it be just an integer as division result made into float without anything after dot?

edit: tested, yes it just gives 0.000000 as i wrote above

ConnorMcLeod 04-03-2011 13:05

Re: devide float by float AMXX problems
 
Have you tried to print result for float(16) and float(24) ?


17.000000 / 23.000000 = 0.739130
ConnorMcLeod : /div 17
PHP Code:

float(str_to_num(szArg2))/float(str_to_num(szArg3)) 

Works fine for me...


All times are GMT -4. The time now is 14:32.

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