Raised This Month: $ Target: $400
 0% 

maths question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
freamer
Member
Join Date: Nov 2005
Old 02-28-2007 , 10:14   maths question
Reply With Quote #1

I would like to know how to multiply/divide floats
for example i have number 33 , i need to get 0.33
if i just write new float:var = 33 / 100.0
it gives me the tag missmatch error and wrong number
ive also tried floatmul and floatdiv but it didnt work

thank you for your help
freamer is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 02-28-2007 , 10:19   Re: maths question
Reply With Quote #2

an example:
PHP Code:
public function(id)
{
    new 
Float:var = 33 100.0
    
    client_print
(id,print_chat,"your health is %f",var)

SAMURAI16 is offline
Send a message via MSN to SAMURAI16
freamer
Member
Join Date: Nov 2005
Old 02-28-2007 , 10:23   Re: maths question
Reply With Quote #3

Code:
public dividef(one, another)
{
    new Float:var = one / another
    return var
}
will this work fine?
freamer is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 02-28-2007 , 10:25   Re: maths question
Reply With Quote #4

no. will got problems with return (tag mismatch)
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
freamer
Member
Join Date: Nov 2005
Old 02-28-2007 , 10:27   Re: maths question
Reply With Quote #5

Quote:
Originally Posted by SAMURAI16 View Post
no. will got problems with return (tag mismatch)
what should i change then?
freamer is offline
SAMURAI16
BANNED
Join Date: Sep 2006
Old 02-28-2007 , 10:28   Re: maths question
Reply With Quote #6

1)First read this : http://wiki.amxmodx.org/index.php/Pawn#Floats It's few lines
2) return another value
SAMURAI16 is offline
Send a message via MSN to SAMURAI16
freamer
Member
Join Date: Nov 2005
Old 02-28-2007 , 10:57   Re: maths question
Reply With Quote #7

im really stuck now
Code:
public dividef(one)
{
    new Float:var = floatround(float(one) / 100.0)
    server_print("%f / %f / %f", float(one), 100.0, float(var))
    return float(var)
}
in console it has written 33.00000 / 100.00000 / 0.0000
why can this happen?

floatdiv gave the same result

removed floatround and all worked fine

Last edited by freamer; 02-28-2007 at 11:46.
freamer is offline
P34nut
AMX Mod X Beta Tester
Join Date: Feb 2006
Location: Netherlands
Old 02-28-2007 , 12:31   Re: maths question
Reply With Quote #8

Code:
public Float:dividef(Float:fOne, Float:fAnother) {     new Float:var = fOne / fAnother     return var }

if it doesnt work

Code:
public Float:dividef(Float:fOne, Float:fAnother) {     new Float:var = floatdiv(fOne, fAnother)     return var }
__________________
All you need to change the world is one good lie and a river of blood
P34nut is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-03-2007 , 07:31   Re: maths question
Reply With Quote #9

Why create vars?
Code:
public Float:dividef(Float:fOne, Float:fAnother)     return fOne / fAnother
equals
Code:
floatdiv(fOne, fAnother)
equals
Code:
fOne / fAnother
You don't even need a function for that.
[ --<-@ ] Black Rose 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 00:37.


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