Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Overflow in LPtoDP function

Overflow in LPtoDP function

Scheduled Pinned Locked Moved C / C++ / MFC
help
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ashtwin
    wrote on last edited by
    #1

    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.

    L 1 Reply Last reply
    0
    • A ashtwin

      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.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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

      A 1 Reply Last reply
      0
      • L Lost User

        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

        A Offline
        A Offline
        ashtwin
        wrote on last edited by
        #3

        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.

        L 1 Reply Last reply
        0
        • A ashtwin

          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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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

          A 1 Reply Last reply
          0
          • L Lost User

            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

            A Offline
            A Offline
            ashtwin
            wrote on last edited by
            #5

            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.

            L 1 Reply Last reply
            0
            • A ashtwin

              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.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              Simple mathematics would suggest that the only way to improve this situation is to find a way of ensuring that the x-value is within a reasonable range. The rules are the rules I am afraid.

              Just say 'NO' to evaluated arguments for diadic functions! Ash

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups