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

[AYUDA]Float devuelve valor incorrecto


  
 
 
Thread Tools Display Modes
Author Message
Porrito
Member
Join Date: Apr 2011
Old 08-28-2012 , 23:00   [AYUDA]Float devuelve valor incorrecto
#1

Buenas
Voy directo al grano:
Estube haciendo una prueba de floats para hacer clases humanas pero al momento de cambiar la string por el float me devuelve el valor pero menos uno.
Aca el Code
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#define PLUGIN "Floats"
#define VERSION "1.0"
#define AUTHOR "Porrito"
new const Gravedad[2][] = { "0.8""0.7" }
public 
plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
register_clcmd"say /prueba""Prueba1")
 
// Add your code here...
}
public 
Prueba1id ){
 
client_print(idprint_chat"%.1f y %.1f y %.1f"str_to_float(Gravedad[0]), str_to_float(Gravedad[1]), str_to_float"0.7" ))
 return 
PLUGIN_HANDLED;

Lo que me sale en el print es lo siguiente:
0.7 y 0.6 y 0.6

Last edited by Porrito; 08-28-2012 at 23:00.
Porrito is offline
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 08-28-2012 , 23:05   Re: [AYUDA]Float devuelve valor incorrecto
#2

hazlo sin el %.1f todos y dime que te devuelve
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
Porrito
Member
Join Date: Apr 2011
Old 08-28-2012 , 23:23   Re: [AYUDA]Float devuelve valor incorrecto
#3

Quote:
Originally Posted by gladius View Post
hazlo sin el %.1f todos y dime que te devuelve
Como no entendi quieres que lo haga asi?
%f
Si es asi me sale el numero decimal bien largo y no aparece el numero
Osea :
0.000000
Porrito is offline
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 08-28-2012 , 23:26   Re: [AYUDA]Float devuelve valor incorrecto
#4

client_print(id, print_chat, "%.f y %.f y %.f", str_to_float(Gravedad[0]), str_to_float(Gravedad[1]), str_to_float( "0.7" ))
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
Porrito
Member
Join Date: Apr 2011
Old 08-28-2012 , 23:30   Re: [AYUDA]Float devuelve valor incorrecto
#5

Me sale lo siguiente :
0. y 0. y 0.
Porrito is offline
gladius
Veteran Member
Join Date: Jul 2008
Location: Santiago, Chile
Old 08-28-2012 , 23:55   Re: [AYUDA]Float devuelve valor incorrecto
#6

Quote:
Originally Posted by Porrito View Post
Me sale lo siguiente :
0. y 0. y 0.
Perdón sin los puntos

%f %f %f
__________________
Proyects
Kreedz Chile Mod [100%] (Fixing some details).

gladius is offline
Send a message via MSN to gladius Send a message via Skype™ to gladius
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 08-28-2012 , 23:56   Re: [AYUDA]Float devuelve valor incorrecto
#7

no es precisa la native.. ami me devolvio esto

Code:
FLOAT=0.800000 | FLOAT2=0.699999 | FLOAT3=0.699999
__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
AfteR.
Veteran Member
Join Date: Dec 2008
Location: λ
Old 08-29-2012 , 14:52   Re: [AYUDA]Float devuelve valor incorrecto
#8

Quote:
Originally Posted by rak View Post
no es precisa la native.. ami me devolvio esto

Code:
FLOAT=0.800000 | FLOAT2=0.699999 | FLOAT3=0.699999
Pero se puede redondear.
AfteR. is offline
Porrito
Member
Join Date: Apr 2011
Old 08-29-2012 , 17:01   Re: [AYUDA]Float devuelve valor incorrecto
#9

Quote:
Originally Posted by rak View Post
no es precisa la native.. ami me devolvio esto

Code:
FLOAT=0.800000 | FLOAT2=0.699999 | FLOAT3=0.699999
Ami me devolvio parecido la diferencia es en el FLOAT 0
Utilizando
PHP Code:
"%.4f" 
Me sale
0.8999 y 0.8000 y 0.4000
Porrito is offline
 



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:07.


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