Calculator project

#include <Keypad.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4);

int i=0;
int s;
char op;
float o;
int nr1[4];
int nr2[4];
float ch1=0;
float ch2=0;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
char keys[ROWS][COLS] = {
  {'1','2','3','A'},
  {'4','5','6','B'},
  {'7','8','9','C'},
  {'*','0','#','D'}
};

byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the Rows of the keypad pin 8, 7, 6, 5 respectively
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup(){
  lcd.init();
  lcd.init();
  lcd.backlight();
  lcd.clear();
   Serial.begin(9600);
}
  
void loop(){
 while(nr1[i-1]<10){ 
    while(!nr1[i]){
    nr1[i] = keypad.getKey()-'0';
    }
    i++;
 }
 s=i;
 for(int f=0; f<i; f++){
  ch1+=nr1[f]*pow(10, i-1-f);
 }
  lcd.print(ch1);
  while(!op){
  op = keypad.getKey();
  }
  if(op=='A'){
    lcd.print("+");
  }else if(op=='B'){
    lcd.print("-");
  }else if(op=='C'){
    lcd.print("*");
  }else if(op=='D'){
    lcd.print("/");
  }else{
    lcd.clear();
    lcd.print(":(");
  }
  while(!ch2){
  ch2 = keypad.getKey();
  }
  lcd.print(ch2);
  lcd.print("=");
  if(op=='A'){
    o=ch1+ch2;
    Serial.println(o);
    lcd.print(o);
  }else if(op=='B'){
    o=ch1-ch2;
    Serial.println(o);
    lcd.print(o);
  }else if(op=='C'){
    o=ch1*ch2;
    Serial.println(o);
    lcd.print(o);
  }else if(op=='D'){
    o=ch1/ch2;
    Serial.println(o);
    lcd.print(o);
  }
   while(!keypad.getKey()){};
  }

I'm trying to make a calculator. When I upload this code -532963.87 appears an the lcd. Why is that? How do I fix this?

Why this?

  lcd.init();
  lcd.init();

I use I2c, so i have to intialize the lcd.

Twice?

yep. I used used it in previous projects so I'm sure its not the reason of the problem

sirKrzysztaq:
yep. I used used it in previous projects so I'm sure its not the reason of the problem

Yes, it is not the reason for the problem. But learning about why it's not necessary to repeat the same action twice in this context is definitely transferable to the trouble shooting skills that would help you solve the problem.

Also do try to make your code readable:
No cryptic two-letter variable names.
Get our indentation right (CTRL-T in the Arduino IDE fixes that).
Liberally sprinkle comments in your code.
As it is, I have no idea what it's supposed to do after a quick read, and I'm not about to try and figure it out the hard way.

You'll love yourself for doing so when you pick up the project again a month later.