File basic for int or float

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By vivid

Hello,
I’m trying to extract from a file a float and an int
for the float I have nothing in return and for the int wrong values in 8,16,32 bits

a file;

0.1/r
4/r

func chargement_fichier():
file = File.new()
file.open("/Users/pat 1/Desktop/manglais.txt",File.READ)
i=file.get_error()

vers = file.get_float()
nbrenr = file.get_8()

I’m looking for examples
Thank you.

:bust_in_silhouette: Reply From: wombatstampede

The get_float() and get_8() methods are for getting binary stored data. Your file is obviously a text file. So just read the strings with get_line() and assign them to your variables.

of course !! … yes load them in ‘string’ to convert them to ‘int’
thank you for waking me up :slight_smile:

vivid | 2019-11-18 17:19