How to convert number to Float?
#1

Hello, i want to ask you, how to convert number to float.

Example:
In script i save PlayerInfo[playerid][Logic] = 100;
but few lines down i need to get Logic converted to float like 100.0

Any ideas how to do it?

Thanks!

// EDIT:

Found this, but didnt work
https://sampwiki.blast.hk/wiki/Float
Reply
#2

it is a function, just use it
Reply
#3

float() should actually do it. How did you use it?

If you use the value inside a calculation, you do not really need to convert it yourself. The compiler will do it for you if you use it like this (for example):

Код:
new Float:some_float = PlayerInfo[playerid][Logic] * 55.0;
The compiler will convert Logic to Float automatically if the other value (55.0 in this case) is a Float already.
Otherwise use float(PlayerInfo[playerid][Logic]) instead.
Reply
#4

Quote:
Originally Posted by NaS
Посмотреть сообщение
float() should actually do it. How did you use it?

If you use the value inside a calculation, you do not really need to convert it yourself. The compiler will do it for you if you use it like this (for example):

Код:
new Float:some_float = PlayerInfo[playerid][Logic] * 55.0;
The compiler will convert Logic to Float automatically if the other value (55.0 in this case) is a Float already.
Otherwise use float(PlayerInfo[playerid][Logic]) instead.
Works, thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)