My EEPROM keeps ressetting to 0.00

Hello guys,

So I'm working on a big code right now, for a game, but there's a problem with my EEPROM, I've never used it before and after a lot of tests I think I knew how it worked. I want to use the EEPROM to save a highscore. Since my code is 370 lines in total I'll only show the parts with the EEPROM that are important. I saw Paul (or someone similair) on an EEPROM thread saying that it can only store like 8 bytes or something, I can vaguely remember something like that.
Here's the part of the code:

#include <EEPROM.h>
float highscore;
int address = 0;

void setup() {
  Serial.begin(9600);
  .....

  void loop() {
    // the loop that runs after you won a game that checks for new highscore:
    ............
    highscore = EEPROM.read(address);
    if (finalTime / 60 < highscore) {
      highscore = finalTime / 60;             // / 60 because I want to see it in minuts.
      EEPROM.write(address, highscore);
    }

    if (finalTime / 60 > highscore) {
      Serial.println("No new highscore");
    }
    .................
  }

So I've set the EEPROM to 3 (minuts) multiple times, and then it'll work once fine, and after that the highscore will be 0.00, someone knows why? I think I'm making a stupid mistake.

Delta_G:
Sigh. You know the problem isn't in these lines. Why don't you either go through the rest of your code and find the mistake or post it here so we can look.

Well the code is 380 lines so I don't know if you want to go through that whole. But it can't actually be in the other because they have nothing to do with the highscore or EEPROM at all.

  highscore = EEPROM.read(address);

EEPROM.read returns . . . what?

AWOL:

  highscore = EEPROM.read(address);

EEPROM.read returns . . . what?

What do you mean exactly :S?

What variable type is finalTime?

I mean, according to the reference, what does EEPROM.read return?

But it can't actually be in the other because they have nothing to do with the highscore or EEPROM at all.

So you say. But, the choice is to either post ALL of your code or fix the problem yourself. You decide.

GypsumFantastic:
What variable type is finalTime?

Float.

AWOL:
I mean, according to the reference, what does EEPROM.read return?

Ehm sorry AWOL I don't really understand you :S. It reads the first block (0) of the EEPROM, but that's not your question I believe.

What data type, according to the EEPROM library reference, does EEPROM.read return?

AWOL:
What data type, according to the EEPROM library reference, does EEPROM.read return?

https://www.arduino.cc/en/Reference/EEPROM ehm it reads the highscore float, I really don't know what you mean, and that link doesn't say a lot about it too..

EEPROM.read() and EEPROM.write() return and take a single byte. Not a float, per the link you posted and the source code for EEPROM.h ( https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/libraries/EEPROM/src/EEPROM.h )

Would EEPROM.get() and EEPROM.put() work for this? Not sure. I don't think I've ever had to do this where I couldn't easily split up the bytes of what I was storing manually, so I haven't played with get and put.

Ooohhh my bad! So basically it returns 0.00.
But at first when I set it to 2.00 (min) and I receive a new highscore it's working and it says "new highscore "new time"" let's say the time is 1.87 min, next time when I do it, it says just 0.00 "No highscore".

GypsumFantastic:
What variable type is finalTime?

akatchi:
Float.

Delta_G:
Another good question not answered because the OP refuses to post the code:

What type is finalTime? Could this be an issue with int math?

No problem.

Delta_G:
Ok. If you're not going to show any code and insist that I solve this by guessing then I'm out. I hope someone else can guess your problem. If not, then when you decide you want to solve it come back and post the code.

I don't get why you immediately get mad on me, I already told you that this is the whole code for the EEPROM, the other part is seperated from this part. I'm not someone who knows everything so there's no need to say that I 'refuse' and didn't 'answer' questions while you didn't even read it.
Instead just don't immediately get mad on people, I'm just asking for help and giving the most information as I can, fine if you don't want to help then don't.

My turn to guess.

Have you by any chance got 2 or more variables with the same name in different scopes and maybe even different types ?

We cannot tell because you have not posted your complete program.

giving the most information as I can

That is exactly what you are not doing.

UKHeliBob:
My turn to guess.

Have you by any chance got 2 or more variables with the same name in different scopes and maybe even different types ?

We cannot tell because you have not posted your complete program.

No Bob I haven't :D, but you guys get me wrong I think, this is the whole code, but seperated from another code because it's bugged, this code itself glitches.

OK, how about we leave you to get on with your debugging?

AWOL:
OK, how about we leave you to get on with your debugging?

I can't figure out the problem.

Me neither.
Have you fixed the problem with reading and writing the float value?