Overflow in LPtoDP function
-
Hi, while using the function LPtoDP i am getting the error "Arithmetic result exceeded 32 bits". I am not able the find the root cause of the problem. I am using x = 1000 in SetViewportExt and x = 500 * (some dynamic value) in SetWindowExt. Is it Ok if i reduce x = 100 in SetViewportExt and x = 50 * (some dynamic value) in SetWindowExt.
-
Hi, while using the function LPtoDP i am getting the error "Arithmetic result exceeded 32 bits". I am not able the find the root cause of the problem. I am using x = 1000 in SetViewportExt and x = 500 * (some dynamic value) in SetWindowExt. Is it Ok if i reduce x = 100 in SetViewportExt and x = 50 * (some dynamic value) in SetWindowExt.
ashtwin wrote:
Is it Ok if i reduce x = 100 in SetViewportExt and x = 50 * (some dynamic value) in SetWindowExt.
Certainly it is, but that does not necessarily solve your problem; in my own experience LPtoDP works fine. The first thing you should be doing is to use your debugger to find out why the overflow is occurring and fix that problem. Then you can decide whether you need to reduce or possibly increase some of your parameter values.
Just say 'NO' to evaluated arguments for diadic functions! Ash
-
ashtwin wrote:
Is it Ok if i reduce x = 100 in SetViewportExt and x = 50 * (some dynamic value) in SetWindowExt.
Certainly it is, but that does not necessarily solve your problem; in my own experience LPtoDP works fine. The first thing you should be doing is to use your debugger to find out why the overflow is occurring and fix that problem. Then you can decide whether you need to reduce or possibly increase some of your parameter values.
Just say 'NO' to evaluated arguments for diadic functions! Ash
Thanks for replying. Actually this error occured only twice and i am not able to reproduce it. I have the following traces Conversion from LPtoDP failed.
>::LPtoDP(dc.GetSafeHdc(), points, noPoints);
noPoints = 2. ViewportExt.cx: 1000 ViewportExt.cy: 616 ViewportOrg.x: 0 ViewportOrg.y: 0 WindowExt.cx: 500 WindowExt.cy: 1000 WindowOrg.x: 68207250 WindowOrg.y: 0 points[0]: x = 68207250 y = 0 points[1]: x = 68207742 y = 1000. But i am not able to find out which parameter value is exceeding.
-
Thanks for replying. Actually this error occured only twice and i am not able to reproduce it. I have the following traces Conversion from LPtoDP failed.
>::LPtoDP(dc.GetSafeHdc(), points, noPoints);
noPoints = 2. ViewportExt.cx: 1000 ViewportExt.cy: 616 ViewportOrg.x: 0 ViewportOrg.y: 0 WindowExt.cx: 500 WindowExt.cy: 1000 WindowOrg.x: 68207250 WindowOrg.y: 0 points[0]: x = 68207250 y = 0 points[1]: x = 68207742 y = 1000. But i am not able to find out which parameter value is exceeding.
Your x values do indeed seem rather large, and it may be that when converting to the device co-ordinates you have exceeded the limit of 27 bits. For example if your mapping is 2 device points to 1 logical, then your x value in device co-ordinates will immediately overflow into 28 bits.
Just say 'NO' to evaluated arguments for diadic functions! Ash
-
Your x values do indeed seem rather large, and it may be that when converting to the device co-ordinates you have exceeded the limit of 27 bits. For example if your mapping is 2 device points to 1 logical, then your x value in device co-ordinates will immediately overflow into 28 bits.
Just say 'NO' to evaluated arguments for diadic functions! Ash
-
Hi, You are correct the x value is the root cause of the problem but i can't avoid this value. Is there any way to avoid overflow by doing some changes.