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. isValidDoubleValue(double *)

isValidDoubleValue(double *)

Scheduled Pinned Locked Moved C / C++ / MFC
performancequestion
14 Posts 6 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.
  • T Tibor Blazko

    is there any (system) function can test memory pointer to know combination of bits there is real (double, float) value? something like this if(isValidDoubleValue(dptr)) dvalue = 0.0; else dvalue = *dptr; //always no exception crash here what will not crash (all i found (like _isnan) expect given bit combination represents valid state and crashes getting invalid one) thanks

    J Offline
    J Offline
    jmkhael
    wrote on last edited by
    #2

    Check IsBadReadPtr to guaranty that you have read access to the memory pointed by dptr Papa while (TRUE) Papa.WillLove ( Bebe ) ;

    T 1 Reply Last reply
    0
    • J jmkhael

      Check IsBadReadPtr to guaranty that you have read access to the memory pointed by dptr Papa while (TRUE) Papa.WillLove ( Bebe ) ;

      T Offline
      T Offline
      Tibor Blazko
      wrote on last edited by
      #3

      yes, but it does not guarantee will not crash next doublevalue = *ptr;

      J 1 Reply Last reply
      0
      • T Tibor Blazko

        yes, but it does not guarantee will not crash next doublevalue = *ptr;

        J Offline
        J Offline
        jmkhael
        wrote on last edited by
        #4

        If you have read access, it wont crash will it? Papa while (TRUE) Papa.WillLove ( Bebe ) ;

        T 1 Reply Last reply
        0
        • T Tibor Blazko

          is there any (system) function can test memory pointer to know combination of bits there is real (double, float) value? something like this if(isValidDoubleValue(dptr)) dvalue = 0.0; else dvalue = *dptr; //always no exception crash here what will not crash (all i found (like _isnan) expect given bit combination represents valid state and crashes getting invalid one) thanks

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #5

          Tibor Blazko wrote: is there any (system) function can test memory pointer to know combination of bits there is real (double, float) value? None that I know of. What's stored at a particular memory location is only important to the application that put it there. In other words, if application A wrote 123.45 to some memory location, it's possible (not to be confused with easy or commonplace) for application B to read that memory location, but application B would not know that those particular bytes represented a double or float.


          "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

          T 1 Reply Last reply
          0
          • J jmkhael

            If you have read access, it wont crash will it? Papa while (TRUE) Papa.WillLove ( Bebe ) ;

            T Offline
            T Offline
            Tibor Blazko
            wrote on last edited by
            #6

            sometimes will _FPE_INVALID

            J J 2 Replies Last reply
            0
            • D David Crow

              Tibor Blazko wrote: is there any (system) function can test memory pointer to know combination of bits there is real (double, float) value? None that I know of. What's stored at a particular memory location is only important to the application that put it there. In other words, if application A wrote 123.45 to some memory location, it's possible (not to be confused with easy or commonplace) for application B to read that memory location, but application B would not know that those particular bytes represented a double or float.


              "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

              T Offline
              T Offline
              Tibor Blazko
              wrote on last edited by
              #7

              i know it should represent double just have data with some uninitialized values (sometimes not valid doubles) and this (crashing ones) i want set to 0.0 in correction step nr.1

              1 Reply Last reply
              0
              • T Tibor Blazko

                sometimes will _FPE_INVALID

                J Offline
                J Offline
                jmkhael
                wrote on last edited by
                #8

                After gaining read access, check for Floating point exceptions Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                T 1 Reply Last reply
                0
                • T Tibor Blazko

                  sometimes will _FPE_INVALID

                  J Offline
                  J Offline
                  Jens Doose
                  wrote on last edited by
                  #9

                  Never heard of that, but a look at MSDN with _FPE_INVALID lead me to SIGFPE and that lead me to signal(), a function you can use to set your own signal handler. I never tried that but maybe this is worth a try? Jens

                  T 1 Reply Last reply
                  0
                  • J jmkhael

                    After gaining read access, check for Floating point exceptions Papa while (TRUE) Papa.WillLove ( Bebe ) ;

                    T Offline
                    T Offline
                    Tibor Blazko
                    wrote on last edited by
                    #10

                    it seems it will end with own fn of this kind just afraid with big data will be exception handling

                    1 Reply Last reply
                    0
                    • J Jens Doose

                      Never heard of that, but a look at MSDN with _FPE_INVALID lead me to SIGFPE and that lead me to signal(), a function you can use to set your own signal handler. I never tried that but maybe this is worth a try? Jens

                      T Offline
                      T Offline
                      Tibor Blazko
                      wrote on last edited by
                      #11

                      it seems it will end with own fn of this kind just afraid with big data will be exception handling slow

                      1 Reply Last reply
                      0
                      • T Tibor Blazko

                        is there any (system) function can test memory pointer to know combination of bits there is real (double, float) value? something like this if(isValidDoubleValue(dptr)) dvalue = 0.0; else dvalue = *dptr; //always no exception crash here what will not crash (all i found (like _isnan) expect given bit combination represents valid state and crashes getting invalid one) thanks

                        C Offline
                        C Offline
                        Chris Meech
                        wrote on last edited by
                        #12

                        I'm might be missing something here, but if it just uninitialised variables, the following might help you out.

                        try
                        {
                        dValue = *dPtr;
                        }
                        catch( . . . )
                        {
                        dValue = 0.0;
                        }

                        Chris Meech We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton VB is like a toolbox, in the hands of a craftsman, you can end up with some amazing stuff, but without the skills to use it right you end up with Homer Simpson's attempt at building a barbeque or his attempt at a Spice rack. Michael P. Butler

                        T 1 Reply Last reply
                        0
                        • T Tibor Blazko

                          is there any (system) function can test memory pointer to know combination of bits there is real (double, float) value? something like this if(isValidDoubleValue(dptr)) dvalue = 0.0; else dvalue = *dptr; //always no exception crash here what will not crash (all i found (like _isnan) expect given bit combination represents valid state and crashes getting invalid one) thanks

                          T Offline
                          T Offline
                          Tim Smith
                          wrote on last edited by
                          #13

                          Take a look at _isnan, _finite and _fpclass. Tim Smith I'm going to patent thought. I have yet to see any prior art.

                          1 Reply Last reply
                          0
                          • C Chris Meech

                            I'm might be missing something here, but if it just uninitialised variables, the following might help you out.

                            try
                            {
                            dValue = *dPtr;
                            }
                            catch( . . . )
                            {
                            dValue = 0.0;
                            }

                            Chris Meech We're more like a hobbiest in a Home Depot drooling at all the shiny power tools, rather than a craftsman that makes the chair to an exacting level of comfort by measuring the customer's butt. Marc Clifton VB is like a toolbox, in the hands of a craftsman, you can end up with some amazing stuff, but without the skills to use it right you end up with Homer Simpson's attempt at building a barbeque or his attempt at a Spice rack. Michael P. Butler

                            T Offline
                            T Offline
                            Tibor Blazko
                            wrote on last edited by
                            #14

                            yes, it seems it will end this way just comment if someone will read this: call _clearfp (or similar) before = 0.0 t!

                            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