I have a problem with loading some numbers (floats) from a text file.
When I load the text file, a string is created containing everything there is in the file. The numbers are separated by a "Tab" and for every 8 numbers the row is changed (or line). I use "scan string" to retrieve each number and then I use "create string" to create a new string where the numbers are separated by only a space.
When I use scan string, I tell the BB to scan for "float". The numbers from the file have up to only 4 decimals max.
When the "scan string" retrieves a float, it adds the missing decimal to the end of each number by adding zeros. That wouldn't be a problem but it doesn't add zeros to every number, there are numbers to which it adds 99 or 01 to the end, and that changes the value of my number.
Then I try to cut off the added numbers using "sub string" to retrieve only 4 decimals. There, 2 others things happen:
Not all my numbers are "edited". Some are left with only 4 decimals.... others are still displayed with 6 decimals.
And some of the numbers that are displayed with less decimals have the last one increased or decreased by 1.
Is there a mistake I'm making when I make the conversions from string to float or when I try to cut off the extra decimals? Why are the values of the numbers changed?
I attached the project to the post. Can someone help me retrieve the right numbers from my file?
The numbers that are changed after cutting off the extra decimals are: 19.2746 -> 19.2745; 19.0318 -> 19.0317
And those which aren't even edited (cut off the 2 extra decimals) are: 18.4626 -> 18.462601; 18.5671 -> 18.567101; 18.0554 -> 18.055401; 18.8026 -> 18.802601; 19.2317 -> 19.231701 etc.