JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

हिंदी माध्यम नोट्स

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi sociology physics physical education maths english economics geography History

chemistry business studies biology accountancy political science

Class 12

Hindi physics physical education maths english economics

chemistry business studies biology accountancy Political science History sociology

Home science Geography

English medium Notes

Class 6

Hindi social science science maths English

Class 7

Hindi social science science maths English

Class 8

Hindi social science science maths English

Class 9

Hindi social science science Maths English

Class 10

Hindi Social science science Maths English

Class 11

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Class 12

Hindi physics physical education maths entrepreneurship english economics

chemistry business studies biology accountancy

Categories: C Language in hindi

C 99 : Floating Point Macro (Part -1 ) in c language in hindi , feclearexcept , fetestexcept , feraiseexcept

feclearexcept , fetestexcept , feraiseexcept , C 99 : Floating Point Macro (Part -1 ) in c language in hindi :-
C 99 मे , floating point variable को handle करने के लिए कई सारे macro को define किया गया है | इन macro से floating point variable के status ,flags और control modes से float point पर control किया जा सकता है |इसमें thread होते है |सभी thread ,प्रोग्राम के initial stage पर अपने parent thread से initial होते  है|floating point operation से इन floating flag के status change हो जाता है |और floating point control signal की value , floating operation के आउटपुट से effect होती है |
floating point macro को use तभी कर सकते है जब pragma_STDC_FENV_ACCESS ,on condition मे होती है |अगर ‘on ‘ condition नहीं होती तब प्रोग्राम नार्मल प्रोग्राम की तरह कार्य करता है |
कुछ C Complier जैसे HP aCC ,Oracle studio और IBM XL मे pragma_STDC_FENV_ACCESS को define करना होता है लेकिन most of the COMPLIER  मे floating point को access कर सकते है |
floating point macro को प्रोग्राम मे add करने के लिए दो प्रकार के declarationको use कर सकते है :-
fenv _t : इस प्रकार के declaration से पुरे floating type macro को use कर सकते है |
fexcept_t : इस प्रकार के declaration से floating type environment मे से flag को ही access कर सकते है |
इस environment मे , निन्म function include होते है :-
1. feclearexcept
इस function का use floating point environment के सभी floating point exception clear करने के लिए किया जाता है |floating point exception का मतलब है floating point related error |अगर सभी flaoting point error clear हो जाती है तब function से ‘0’ return होगा अन्यथा ‘1’ return होगा |
इस function मे excepts( bitmask listing the exception flags  to clear) ,argument की तरह pass होता है और बिट ‘0’ या ‘1’ return होता है |
#include<stdio.h>
#include<conio.h>
#include<fenv.h>
#include<math.h>
# pragma_STDC_FENV_ACCESS on
void main()

 

{
int a;

 

printf(“Enter Data”);
scanf(“%d”,&a);
float b=sqrt(a);
feclearexcept (FE_ALL_EXCEPT);
if(feclearexcept (FE_INVALID))
{
printf(“User input negative value.\n”);
printf(“Sqrt(input) can not calculate.”);
}
else
{
printf(“sqrt(input) = %f”,b);
}
getch();
}
अगर द्वारा input की गयी value नेगेटिव होती है तब square root find नहीं हो सकता है |और error message print हो जाता है |
आउटपुट होगा :
Enter data -4
User input negative value
Sqrt(input) can not calculate.
2. fetestexcept
इस macro का use , floating point error को find करने के लिए किया जाता है |इस macro से floating point
error को specify किया जाता है |इसमें pre set floating point code होते है जिनके occur होने पर हम error को indentify किया जा सकता है |
इसके लिए pre set error codes होते है :
1.FE_DIVBYZERO : ये तब occur होती है जब किसी integer को ‘0’ से डिवाइड किया जाता |है
2.FE_INEXACT :ये तब occur होती है जब किसी expression का आउटपुट अशांत floating number हो |
3.FE_INVALID : जब किसी function मे invalid argument को pass किया जाता है जिसका आउटपुट  floating point number हो |
4.FE_OVERFLOW: जब किसी expression के आउटपुट की range ओवर हो जाती है |
5.FE_UNDERFLOW:जब किसी expression के आउटपुट की range,float number की range से बहुत कम  होती है |
इसका उदाहरण होगा
#include<stdio.h>
#include<conio.h>
#include<fenv.h>
#include<math.h>
# pragma_STDC_FENV_ACCESS on
void main()

 

{
int a;

 

printf(“Enter Data”);
scanf(“%d”,&a);
printf(“square root = %f “, sqrt (a));
int d=a/0;
printf(” %d/0 = %f  “, a,d );
printf(“Power Function = %f”,a/pow(2,45));
error();
getch();
}
void error()
{
printf(“Error”);
if ( fetestexcept (FE_DIVBYZERO) )
printf(“Divide by zero”);
if ( fetestexcept (FE_INEXACT) )
printf(” Inexact error “);
if ( fetestexcept (FE_INVALID) )
printf(“Invalid argument error”);
if ( fetestexcept (FE_OVERFLOW) )
printf(“Overflow Error”);
if ( fetestexcept (FE_UNDERFLOW) )
printf (” Underflow Error”);
}
आउटपुट होगा :
Enter data -3
square root = -nan
-3/0 = inf
Power Function = inf
Error
Invalid argument error
Divide by zero
Overflow Error
3. feraiseexcept
इस function का use सभी error को find करने के लिए के लिए किया जाता है | इसमें macro मे सभी error codes लॉजिकल OR operation के pass होती है | जैसे अगर किसी प्रोग्राम मे , overflow या underflow error आती है तब Inexact error  भी जरुर होगी इसलिए in दोनों error message को print किया जाता है |
इसका उदहारण है :-
#include<stdio.h>
#include<conio.h>
#include<fenv.h>
#include<math.h>
# pragma_STDC_FENV_ACCESS on
void main()

 

{
int a;

 

printf(“Enter Data”);
printf(“Power Function = %f”,a/pow(2,45));
if(feraiseexcept (FE_DIVBYZERO | FE_INEXACT | FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW )
{
printf(“Feraiseexcept Happend “)
error();
}
getch();
}
void error()
{
printf(“Error”);
if ( fetestexcept (FE_DIVBYZERO) )
printf(“Divide by zero”);
if ( fetestexcept (FE_INEXACT) )
printf(” Inexact error “);
if ( fetestexcept (FE_INVALID) )
printf(“Invalid argument error”);
if ( fetestexcept (FE_OVERFLOW) )
printf(“Overflow Error”);
if ( fetestexcept (FE_UNDERFLOW) )
printf (” Underflow Error”);
}
आउटपुट होगा :
Enter data -3
Power Function = inf
Feraiseexcept Happend
Error
Inexact error
Overflow Error
4. fegetexceptflag ,fesetexceptflag
इन macro statement से किसी floating point environment से current flag के status को copy किया जाता है |in status को प्रोग्राम मे बाद मे use किया जा सकता है |
4.i)fegetexceptflag
इस macro का use , किसी floating point environment से flag के status को copy किया जाता है |इस function मे दो argument pass होते है | (i) fexcept_t type का variable जिसमे current flag का status store होता है | (ii) excepts का नाम |
4.ii) fesetexceptflag
इस macro का use , किसी floating point environment से flag के status को paste किया  जाता है |इस function मे दो argument pass होते है | (i) fexcept_t type का variable जिसमे current flag का status store होते है | (ii) excepts का नाम जिसमे flag के status को paste करना है  |
उदाहरण के लिए
#include<stdio.h>
#include<conio.h>
#include<fenv.h>
#include<math.h>
# pragma_STDC_FENV_ACCESS on
void main()

 

{
fexcept_t exc;
feraiseexcept(FE_DIVBYZERO)
error();
fegetexceptflag(&exc , FE_ALL_EXCEPT);
feclearexcept (FE_ALL_EXCEPT);
feraiseexcept(FE_DIVBYZERO | FE_OVERFLOW)
error();
feclearexcept (FE_ALL_EXCEPT);
fesetexceptflag (&exc , FE_ALL_EXCEPT );
error();
feclearexcept (FE_ALL_EXCEPT);
getch();
}
void error()
{
printf(“Error”);
if ( fetestexcept (FE_DIVBYZERO) )
printf(“Divide by zero”);
if ( fetestexcept (FE_INEXACT) )
printf(” Inexact error “);
if ( fetestexcept (FE_INVALID) )
printf(“Invalid argument error”);
if ( fetestexcept (FE_OVERFLOW) )
printf(“Overflow Error”);
if ( fetestexcept (FE_UNDERFLOW) )
printf (” Underflow Error”);
}
आउटपुट होगा :
Divide by zero
Divide by zero
Overflow Error
Overflow Error
इस article मे , asthmatic operation related exception को पढ़ा |अब हम C 99 : Floating Point Macro (Part -2 ) मे direction related exception को पढेगे |
Sbistudy

Recent Posts

द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन क्या हैं differential equations of second order and special functions in hindi

अध्याय - द्वितीय कोटि के अवकल समीकरण तथा विशिष्ट फलन (Differential Equations of Second Order…

13 hours ago

four potential in hindi 4-potential electrodynamics चतुर्विम विभव किसे कहते हैं

चतुर्विम विभव (Four-Potential) हम जानते हैं कि एक निर्देश तंत्र में विद्युत क्षेत्र इसके सापेक्ष…

3 days ago

Relativistic Electrodynamics in hindi आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा

आपेक्षिकीय विद्युतगतिकी नोट्स क्या है परिभाषा Relativistic Electrodynamics in hindi ? अध्याय : आपेक्षिकीय विद्युतगतिकी…

5 days ago

pair production in hindi formula definition युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए

युग्म उत्पादन किसे कहते हैं परिभाषा सूत्र क्या है लिखिए pair production in hindi formula…

1 week ago

THRESHOLD REACTION ENERGY in hindi देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा

देहली अभिक्रिया ऊर्जा किसे कहते हैं सूत्र क्या है परिभाषा THRESHOLD REACTION ENERGY in hindi…

1 week ago
All Rights ReservedView Non-AMP Version
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings
JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now