help with math

ckiick:
It would be much easier to help you if you posted the code, or at least gave some sample inputs and outputs. Otherwise we are just guessing at what the problem is.

One thing is that to preserve accuracy, you need to re-arrange the calculation a little. Also, if you want unsigned long results, you should use unsigned long constants and variables in the calculation as much as possible.

delay = 1000UL * (m * 60UL)) + s) / (passes * 49);

what is UL?

here is part od code:

#include <SoftwareSerial.h>

SoftwareSerial ser(2,3);

//Pin connected to latch pin (ST_CP) of 74HC595
const int latchPin = 8;
//Pin connected to clock pin (SH_CP) of 74HC595
const int clockPin = 12;
////Pin connected to Data in (DS) of 74HC595
const int dataPin = 11;
//Pin connected to data of third 595
const int dataPin2 =6;
byte pass=1;
unsigned long int wait= 500;

void setup() {
  ser.begin(19200);
  delay(100);
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin2, OUTPUT);
}

void loop() {
  
  
  //unos podataka
  ser.print("\eO770;1000~");//start beep



ser.print('\f');  
ser.println("50m :"); //number of pass
response=get_int(); // Get an integer number from phi-panel
int pass=response;
ser.print('\f');
ser.println("Metars:");
ser.print(pass*50);
ser.print(" m");
delay(1000);

ser.print('\f');  
ser.println("Enter minutes:"); //minutes
response=get_int(); // Get an integer number from phi-panel
int minutes=response;
ser.print('\f');
ser.print(minutes);
ser.print(" minutes");
delay(1000);

ser.print('\f'); 
ser.println("Enter seconds:"); // seconds
response=get_int();
int sec=response;
ser.print('\f');
ser.print(sec);
ser.println(" seconds");
delay(1000);


  
wait=(((minutes*60)+sec)*1000)/(49*pass); //calculation of delay