JOIN us on
WhatsApp Group Join Now
Telegram Join Join Now

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

Categories: C Language in hindi

C 99 : Floating Point Macro (Part 2) in c language in hindi , FEGETROUND ,FESETROUND , FEGETENV ,FESETENV

FEGETROUND ,FESETROUND , FEGETENV ,FESETENV , C 99 : Floating Point Macro (Part 2) in c language in hindi :-
इससे पहले वाले article मे , हमने arthmatic operation related error को पढ़ा |अब इस article मे , floating number को rounding को पढेगे |सबसे पहले recap करेगे |
इस header file मे निन्म  macro होते है |
1. FE_DIVBYZERO : ये तब occur होती है जब किसी integer को ‘0’ से डिवाइड किया जाता |है
2. FE_INEXACT :ये तब occur होती है जब किसी expression का आउटपुट अशांत flaoting number हो |
3. FE_INVALID : जब किसी function मे invalid argument को pass किया जाता है जिसका आउटपुट  floating point number हो |
4. FE_OVERFLOW: जब किसी expression के आउटपुट की range ओवर हो जाती है |
5.FE_UNDERFLOW:जब किसी expression के आउटपुट की range,float number की range से बहुत कम  होती है |
इनके अलावा इस header file मे  floating number के rounding के लिए macro होते है :-
1. FE_DOWNWORD : इस macro का use , floating number को negative infinity की तरफ movement करने के लिए किया जता है |
2. FE_TONEAREST : इस macro का use , floating number को nearest represtable number की ओर movement के लिए किया जाता है |
3. FE_TOWARDZERO : इस macro का use , floating number को zero की ओर movement करने के लिए किया जाता है |
4. FE_UPWARD: इस macro का use , floating number को positive infinity की तरफ movement करने  के लिए किया जाता है |
ये सभी macro constant , non negative integer constant expression  से expand किया जाता है | इस use करने के लिए std:: fesetround और std:: fegetround को use किया जाता है |
l सभी floating rounding का use किया जाता है :-
1.किसी arithmatic operation जिसका type constant expression होता है |
2. किसी standard function के आउटपुट मे |
3.floating point से floating point implicit conversion मे |
4.string conversion मे |
5.Libarary rounding function (nearbyint , rint , lrint आदि) मे |
इसकेअलावा rounding निन्म को effect नहीं करता है |
1.floating point तो integer type conversion
2.किसी airthmatic operation जो run time पर execute होता है |
3.libary  rounding function ( round, lround , llround , ceil, floor आदि ) मे

Function

1. fegetround ,fesetround

इन macro statement से किसी floating point के rounding mode को set/ reset करने के लिए  किया जाता है |इन्हें set/reset करने के बाद libary rounding function को use किया जाता है |
1.i)fegetround
इस macro का use , किसी floating point variable के mode को उपर दिए  गये चार modes मे से एक mode को सेलेक्ट करने के लिए  किया जाता है |इस function मे एक ही argument pass होते है | (i) mode का नाम | ये macro ‘0’ return करता है अगर rounding success हो जाती है |अन्यथा ‘1’ return होता है |
1.ii)fesetround
इस macro का use , किसी floating point variable के mode को उपर दिए  गये चार modes मे से एक mode को reset करने के लिए  किया जाता है |इस function मे एक ही argument pass होते है | (i) mode का नाम | ये macro ‘0’ return करता है अगर rounding success हो जाती है |अन्यथा ‘1’ return होता है |
उदाहरण के लिए :
#include<stdio.h>
#include<conio.h>
#include<cfenv.h>
#include<math.h>
void main()
{
float a , b;
printf(“Enter a Floating Number”);
scnaf(“%f”, & a);
printf(“Enter another Floating Number “);
scanf(“%f”,&b);
fegetround (FE_DOWNWORD);
printf(“Value =%f”, floor(a));
printf(“Value =%f”, nerbyint(a));
printf(“Value =%f”, nerbyint(b));
printf(“Value =%f”, floor(b));
fesetround(FE_TONEAREST)
printf(“Value =%f”, floor(a));
printf(“Value =%f”, nerbyint(a));
printf(“Value =%f”, nerbyint(b));
printf(“Value =%f”, floor(b));
getch()
}
इस उदाहरण मे , सबसे पहले FE_DOWNWARD rounding को set किया गया है फिर floor और nearbyint function को call किया है |
बाद मे , FE_TONEAREST rounding को  FE_DOWNWARD के जगह रिसेट किया गया है और  floor और nearbyint function को call किया है |
इसका आउटपुट होगा |
Enter a Floating Number 23.3
Enter another Floating Number 45.5
Value =23
Value =23
Value =45
Value =45
Value =24
Value =24
Value =24
Value =24

2. fegetenv ,fesetenv

इन macro statement से किसी floating point के rounding mode को access करके use किसी भी समय पर set  करने के लिए  किया जाता है |इन्हें set करने के बाद libary rounding function को use किया जाता है |
1.i)fegetenv
इस macro का use , किसी floating point variable के current mode को copy करने के लिए  किया जाता है |इस function मे एक ही argument pass होते है | (i)fenv_t type का pointer को pass किया जाता जो current mode को hold करता है  | ये macro ‘0’ return करता है अगर rounding success हो जाती है |अन्यथा ‘1’ return होता है |
1.ii)fesetround
इस macro का use , fegetenv से copy किया गया mode को  set करने के लिए  किया जाता है |इस function मे एक ही argument pass होते है | (i) fenv_t type का pointer को pass किया जाता जिसमे  current mode को hold है  | | ये macro ‘0’ return करता है अगर rounding success हो जाती है |अन्यथा ‘1’ return होता है |
उदाहरण के लिए :
#include<stdio.h>
#include<conio.h>
#include<cfenv.h>
#include<math.h>
void main()
{
fenv_t *type;
float a , b;
printf(“Enter a Floating Number”);
scnaf(“%f”, & a);
printf(“Enter another Floating Number “);
scanf(“%f”,&b);
fegetround (FE_DOWNWORD);
printf(“Value =%f”, floor(a));
printf(“Value =%f”, nerbyint(-12.56));
printf(“Value =%f”, nerbyint(b));
printf(“Value =%f”, floor( 12.70));
fegetenv(type);
fesetround(FE_TONEAREST)
printf(“Value =%f”, floor(a));
printf(“Value =%f”, nerbyint(12.65));
printf(“Value =%f”, nerbyint(b));
printf(“Value =%f”, floor(b));
fesetround(type)
printf(“Value =%f”, floor(a));
printf(“Value =%f”, nerbyint(34.6));
printf(“Value =%f”, nerbyint(b));
printf(“Value =%f”, floor(b));
getch()
}
इस उदाहरण मे , सबसे पहले FE_DOWNWARD rounding को set किया गया है फिर floor और nearbyint function को call किया है |
बाद मे , FE_TONEAREST rounding को  FE_DOWNWARD के जगह रिसेट किया गया है और  floor और nearbyint function को call किया है |
इसका आउटपुट होगा |
Enter a Floating Number 23.3
Enter another Floating Number 45.5
Value =23
Value = -13
Value =45
Value =12
Value =24
Value =12
Value =45
Value =45
Value =24
Value =34
Value =45
Value =45
इस प्रकार से floating point मे rounding mode को set करने की facility C99 मे होती  है |
Sbistudy

Recent Posts

सती रासो किसकी रचना है , sati raso ke rachnakar kaun hai in hindi , सती रासो के लेखक कौन है

सती रासो के लेखक कौन है सती रासो किसकी रचना है , sati raso ke…

21 hours ago

मारवाड़ रा परगना री विगत किसकी रचना है , marwar ra pargana ri vigat ke lekhak kaun the

marwar ra pargana ri vigat ke lekhak kaun the मारवाड़ रा परगना री विगत किसकी…

21 hours ago

राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए sources of rajasthan history in hindi

sources of rajasthan history in hindi राजस्थान के इतिहास के पुरातात्विक स्रोतों की विवेचना कीजिए…

3 days ago

गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है ? gurjaratra pradesh in rajasthan in hindi

gurjaratra pradesh in rajasthan in hindi गुर्जरात्रा प्रदेश राजस्थान कौनसा है , किसे कहते है…

3 days ago

Weston Standard Cell in hindi वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन

वेस्टन मानक सेल क्या है इससे सेल विभव (वि.वा.बल) का मापन Weston Standard Cell in…

3 months ago

polity notes pdf in hindi for upsc prelims and mains exam , SSC , RAS political science hindi medium handwritten

get all types and chapters polity notes pdf in hindi for upsc , SSC ,…

3 months 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