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

[ES] Duda con floats (EDITE)


  
 
 
Thread Tools Display Modes
Author Message
PattyBiena
BANNED
Join Date: Jul 2010
Location: Argentina
Old 07-16-2010 , 18:37   [ES] Duda con floats (EDITE)
#1

Como hago para que esta cuenta me de Este resultado.

a / b = 0.XXX

Quiero que devuelva XX.X

Ejemplo:

39 / 40 = 0.975

Yo quiero que me devuelva 97.5

(es un ejemplo los numeros varian pero siempre a es menor a b)

Last edited by PattyBiena; 07-16-2010 at 19:09.
PattyBiena is offline
frk_14
Senior Member
Join Date: Jan 2009
Location: Argentina
Old 07-16-2010 , 21:30   Re: [ES] Duda con floats (EDITE)
#2

Quote:
Originally Posted by PattyBiena View Post
Como hago para que esta cuenta me de Este resultado.

a / b = 0.XXX

Quiero que devuelva XX.X

Ejemplo:

39 / 40 = 0.975

Yo quiero que me devuelva 97.5


(es un ejemplo los numeros varian pero siempre a es menor a b)
a/b*10?
edit: que bruto que soy

Last edited by frk_14; 07-17-2010 at 00:33.
frk_14 is offline
Send a message via MSN to frk_14 Send a message via Skype™ to frk_14
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 07-16-2010 , 23:06   Re: [ES] Duda con floats (EDITE)
#3

Quote:
Originally Posted by frk_14 View Post
a/b*10?
* 100

PD: Es cuestion de usar un poco de matematica u.u
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
PattyBiena
BANNED
Join Date: Jul 2010
Location: Argentina
Old 07-17-2010 , 00:20   Re: [ES] Duda con floats (EDITE)
#4

Te amo (LL

Otra (aca salta spid seguro J3)

PHP Code:
new const LEVELS[2] = { 2540 }

client_print(0print_chat"Porcentaje %0.2f", (LEVELS[0] / LEVELS[1]) * 100
Xq no sale desde 0.00% u.u!?

Last edited by PattyBiena; 07-17-2010 at 00:23.
PattyBiena is offline
frk_14
Senior Member
Join Date: Jan 2009
Location: Argentina
Old 07-17-2010 , 01:00   Re: [ES] Duda con floats (EDITE)
#5

Quote:
Originally Posted by PattyBiena View Post
Te amo (LL

Otra (aca salta spid seguro J3)

PHP Code:
new const LEVELS[2] = { 2540 }

client_print(0print_chat"Porcentaje %0.2f", (LEVELS[0] / LEVELS[1]) * 100
Xq no sale desde 0.00% u.u!?
Tenés que usar floats.

PHP Code:
client_print(0print_chat"Porcentaje %0.2f ", (float (LEVELS[0]) /  float (LEVELS[1])) * 100.0
Me parece a mi :S.

Last edited by frk_14; 07-17-2010 at 01:02.
frk_14 is offline
Send a message via MSN to frk_14 Send a message via Skype™ to frk_14
Old 07-17-2010, 01:03
Exc3ll@N
This message has been deleted by Alucard^.
AfteR.
Veteran Member
Join Date: Dec 2008
Location: λ
Old 07-17-2010 , 01:03   Re: [ES] Duda con floats (EDITE)
#6

No es %.2f ?
AfteR. is offline
Old 07-17-2010, 01:04
Celeron
This message has been deleted by Alucard^.
Old 07-17-2010, 01:07
Exc3ll@N
This message has been deleted by Alucard^.
Old 07-17-2010, 01:58
01101101
This message has been deleted by Alucard^.
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 07-17-2010 , 02:12   Re: [ES] Duda con floats (EDITE)
#7

Quote:
Originally Posted by PattyBiena View Post
Te amo (LL

Otra (aca salta spid seguro J3)

PHP Code:
new const LEVELS[2] = { 2540 }

client_print(0print_chat"Porcentaje %0.2f", (LEVELS[0] / LEVELS[1]) * 100
Xq no sale desde 0.00% u.u!?
No entendi la pregunta final... como que porque no sale 0.00%?

De todas formas, si no me equivoco lo que te serviria seria esto:

Code:
    new const LEVELS[2] = { 25, 40 };         new Float:fLevels = float( (LEVELS[0] / LEVELS[1]) * 100);         client_print(0, print_chat, "Porcentaje %.2f", fLevels);

Obviamente se puede sin crear la variable fLevels y hacerle un float directamente en el ultimo parametro del client_print( ), pero para mejor lectura o entendimiento del codigo lo hice asi.

@ After

Creo que funca de las 2 formas, con el 0 o sin el 0, yo aca lo puse sin el 0 por las dudas.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
Celeron
Senior Member
Join Date: Jul 2010
Location: Argentina - Mendoza
Old 07-17-2010 , 02:23   Re: [ES] Duda con floats (EDITE)
#8

Una preguntita desvirtue:

Que programa usas: PawnS o AMXXS?
__________________
Celeron is offline
Send a message via MSN to Celeron
PattyBiena
BANNED
Join Date: Jul 2010
Location: Argentina
Old 07-17-2010 , 11:18   Re: [ES] Duda con floats (EDITE)
#9

Pawn
@alu

Quise decir ponele, entre el numero 25 a 40 que me tire 0,0%
Y valla subiendo hasta llegar al 40 al llegar al 40 que sea 100,0%

Nose si se entiende :B
PattyBiena is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viña del Mar, Chile
Old 07-17-2010 , 17:23   Re: [ES] Duda con floats (EDITE)
#10

Osea, tal como dice alucard, es cosa de usar la matematica, como la Notacion Cientifica, Nº * 10^x, segun X sea las veces que quisieses aumentar la coma.
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Old 07-17-2010, 19:05
Starsailor
This message has been deleted by Starsailor. Reason: Flashie
 



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 09:45.


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