CLEO Help [SOLVED] cutting floats

CLEO related
Status
Not open for further replies.

Kelsi235

Active member
Joined
Jun 2, 2019
Messages
53
Reaction score
4
for example i have a
6.214698385312
52.3532355533

how do I cut it to
6.21
52.35

aka

6.2100000000
52.350000000


(i need them to still be float and not an string)
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
there are opcodes that allow conversion from float to int and from int to float (use opcode search tool in sanny builder or google), using these you can do the following:

Code:
new_float = float(int(6.214698385312 * 100.0)) / 100.0

new_float becomes 6.21
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
__________________________________________

alternatively you could use "format" and "scan_string" opcodes like:
format str_pointer "%.2f" old_float
scan_string str_pointer "%f" new_float
 
Status
Not open for further replies.
Top