P
Paul Cheetham
Hi,
I am developing a program that is doinbg time calculations using Ticks.
Below is a piece of code that is causing an arithmetic overflow
exception - the single line inside the try statement.
All the variables are defined as ulong, the difference between JobStart
and LineStart is approx 584 000 000 000, and TicksPerPix is approx. 909
000 000
Can anyone see what I can't after staring at it for hours?
Thankyou.
Paul
ulong TicksPerPix, LineStart, JobStart, JobLeft;
TimeSpan time = _lineEndTime - _lineStartTime;
LineStart = (ulong)_lineStartTime.Ticks;
JobStart = (ulong)newJob.StartTime.Ticks;
TicksPerPix = (ulong)time.Ticks / (ulong)Width;
try
{ // The next line generates an Arithmetic Overflow!
JobLeft = ((ulong)(JobStart - LineStart) / (ulong)TicksPerPix);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception");
}
I am developing a program that is doinbg time calculations using Ticks.
Below is a piece of code that is causing an arithmetic overflow
exception - the single line inside the try statement.
All the variables are defined as ulong, the difference between JobStart
and LineStart is approx 584 000 000 000, and TicksPerPix is approx. 909
000 000
Can anyone see what I can't after staring at it for hours?
Thankyou.
Paul
ulong TicksPerPix, LineStart, JobStart, JobLeft;
TimeSpan time = _lineEndTime - _lineStartTime;
LineStart = (ulong)_lineStartTime.Ticks;
JobStart = (ulong)newJob.StartTime.Ticks;
TicksPerPix = (ulong)time.Ticks / (ulong)Width;
try
{ // The next line generates an Arithmetic Overflow!
JobLeft = ((ulong)(JobStart - LineStart) / (ulong)TicksPerPix);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Exception");
}