Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Program ends unexpectedly when I change the vector type from float to double
Forum Updated to NodeBB v4.3 + New Features

Program ends unexpectedly when I change the vector type from float to double

Scheduled Pinned Locked Moved General and Desktop
10 Posts 5 Posters 3.4k 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.
  • R Offline
    R Offline
    rwhitte2
    wrote on last edited by
    #1

    Having issue with a code I am writing for a class and got it to work with floating point numbers, but whenever I change all the variables to being doubles instead of floats (so I can get better precision) it ends unexpectedly after ~25 iterations. The floating point version of the program solved it in 28 iterations. The calculations seem to be printing out completely different results from the beginning. Anyone have any idea of whats going on with it?

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vsorokin
      wrote on last edited by
      #2

      Can give more information? show your code, show concrete error text?

      --
      Vasiliy

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rwhitte2
        wrote on last edited by
        #3

        This is the last bit it outputs (note that it interrupts the cout the last line should read .62439 hc inside) I would provide code but its very lengthy and there is not one portion that I can think of to describe the error. Would it be helpful to see how I initialized the vectors?

        21
        -36.225 Temp 1
        2.83614 hr for outside
        30.8 hc for outside
        0.624329 hThe program has unexpectedly finished.

        exited with code -1073741819

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          I supose we need to see the code to tell, what is going wrong. showing only number says nothing.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          1 Reply Last reply
          0
          • AlicemirrorA Offline
            AlicemirrorA Offline
            Alicemirror
            wrote on last edited by
            #5

            @Gerolf: yep :)

            I think maybe a problem of number alignement or some trouble connected to 32 / 64 bit. Maybe ?

            Enrico Miglino (aka Alicemirror)
            Balearic Dynamics
            Islas Baleares, Ibiza (Spain)
            www.balearicdynamics.com

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lgeyer
              wrote on last edited by
              #6

              As others have said you will have to provide the code.

              Keep in mind that floating point arithmetic is never exact. There will always be round-off errors and the result usually depends on the order of the instructions, the precision and length of datatypes, the compiler and the processor. If you change just one of them results may vary.

              For the same reason you cannot compare floating point numbers to exact values. A frequent error in floating point arithmetic is comparison against 0 and thus missing loop exit conditions. You should always use "qFuzzyCompare":http://doc.qt.nokia.com/4.7-snapshot/qtglobal.html#qFuzzyCompare-2 to compare floating point numbers.

              In addition, using double precision is usually as fast as using float precision and should thus always be preferred.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rwhitte2
                wrote on last edited by
                #7

                header
                https://docs.google.com/document/d/1P2wZnlRmZ7B-WOYfjDvUNnOG8SKMXv20d9GAlWENY4E/edit?hl=en_US
                main
                https://docs.google.com/document/d/1HgGkStkj4kRSA5a-eYSGDBTr1w_7pJJUnMJxrgVQR4g/edit?hl=en_US
                functions
                https://docs.google.com/document/d/1NOJutLv5z6oGPXHrh6MJA5pNEvEDPM1dlaiB7LHD5os/edit?hl=en_US

                1 Reply Last reply
                0
                • AlicemirrorA Offline
                  AlicemirrorA Offline
                  Alicemirror
                  wrote on last edited by
                  #8

                  As I know, a forum is a place where other developers - volunteers - try to help others.

                  This means that - as I think about - when I need help I try to simplify as possible my question, giving on the post as many information, an example that explain the problem (writing the code) and - when possible - and example that exclude all the code showing the issue as possible out-of-context of my application. Then I can also add lnks "for further details and informations" where the users can find the entire project, the code or whathever else.

                  Without offending anyone, the approach of thie request seems a case opened to a - paid - technical support, not a thread that will be helpful for the communityt and help someone to solve his problems.

                  Enrico Miglino (aka Alicemirror)
                  Balearic Dynamics
                  Islas Baleares, Ibiza (Spain)
                  www.balearicdynamics.com

                  1 Reply Last reply
                  0
                  • L Offline
                    L Offline
                    lgeyer
                    wrote on last edited by
                    #9

                    In addition, posting code on "pastebin.com":http://pastebin.com/ (or alike) provides syntax highlighting, indention support due to fixed width font and annotations. Reading code in Google docs is a PITA.

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      rwhitte2
                      wrote on last edited by
                      #10

                      Alright, thanks for the help. I agree that writing the code out of context would have been the best route, but there really was no one place that I could single out to help demonstrate my issue without providing all of the code (which is why I didn't provide it originally). I did figure out how to get it to run for some reason the size() function in a for loop created issues but when I changed it to end at a value it ran. Sorry if I have offended anyone for the way I asked for help, just had no idea what could be causing the error.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved