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. _controlfp() - function

_controlfp() - function

Scheduled Pinned Locked Moved C / C++ / MFC
c++hardwarehelp
4 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.
  • D Offline
    D Offline
    durban2
    wrote on last edited by
    #1

    MFC, STUDIO'2008, WINDOWS'XP 2003 #include <float.h> _controlfp(_DN_FLUSH, _MCW_DN); // : error C3861: '__controlfp': identifier not found // Denormal values flushed to zero by hardware on ALPHA and x86 // processors with SSE2 support. Ignored on other x86 platforms. below some variants: //+-1 _controlfp(0, MCW_EM); <float.h> // below following line is incorrect - don't display MessageBox(L"1\nDIVIDE BY ZERO"); _controlfp(_DN_FLUSH, _MCW_DN); _controlfp(0, _MCW_DN); _controlfp(_DN_SAVE, _MCW_DN); _controlfp(0, _MCW_DN); int err; double fResult; // Bennet, pg.136 double x,y; x = 5.0; y = 0.0; _try { fResult = x/y; // _control87_2(0, 0,&fResult, 0); //- _controlfp(0, 0,&fResult, 0); // : error C2660: '_controlfp' : function does not take 4 arguments //- _controlfp(&fResult, 0); // : error C2664: '_controlfp' : cannot convert parameter 1 from 'float *' to 'unsigned int' } _except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO) { MessageBox(L"1\nDIVIDE BY ZERO"); MessageBox(_T("2\nDIVIDE BY ZERO")); AfxMessageBox(_T("3\nDIVIDE BY ZERO")); }

    C 1 Reply Last reply
    0
    • D durban2

      MFC, STUDIO'2008, WINDOWS'XP 2003 #include <float.h> _controlfp(_DN_FLUSH, _MCW_DN); // : error C3861: '__controlfp': identifier not found // Denormal values flushed to zero by hardware on ALPHA and x86 // processors with SSE2 support. Ignored on other x86 platforms. below some variants: //+-1 _controlfp(0, MCW_EM); <float.h> // below following line is incorrect - don't display MessageBox(L"1\nDIVIDE BY ZERO"); _controlfp(_DN_FLUSH, _MCW_DN); _controlfp(0, _MCW_DN); _controlfp(_DN_SAVE, _MCW_DN); _controlfp(0, _MCW_DN); int err; double fResult; // Bennet, pg.136 double x,y; x = 5.0; y = 0.0; _try { fResult = x/y; // _control87_2(0, 0,&fResult, 0); //- _controlfp(0, 0,&fResult, 0); // : error C2660: '_controlfp' : function does not take 4 arguments //- _controlfp(&fResult, 0); // : error C2664: '_controlfp' : cannot convert parameter 1 from 'float *' to 'unsigned int' } _except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO) { MessageBox(L"1\nDIVIDE BY ZERO"); MessageBox(_T("2\nDIVIDE BY ZERO")); AfxMessageBox(_T("3\nDIVIDE BY ZERO")); }

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #2

      And the question is? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      D 1 Reply Last reply
      0
      • C CPallini

        And the question is? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        D Offline
        D Offline
        durban2
        wrote on last edited by
        #3

        Why don't exec MessageBox(L"1\nDIVIDE BY ZERO");

        C 1 Reply Last reply
        0
        • D durban2

          Why don't exec MessageBox(L"1\nDIVIDE BY ZERO");

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #4

          The following code works fine on my system

          #include "Excpt.h"
          #include #include "cmath"
          #include void main()
          {
          _controlfp(0, MCW_EM);
          float fResult; // Bennet, pg.136
          //int x,y;
          float x,y;
          // x = 5;
          // y = 0;

          x = 5.0;
          y = 0.0;
          _try // __try
          {
          fResult = x/y;
          }
          //__except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO)
          _except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO)
          {
          MessageBox(NULL, L"DIVIDE BY ZERO", L"", MB_OK);
          }
          }

          :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          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