এক দশমিক সংখ্যার সাংখ্যিক বাস্তবায়ন হল ফ্লোটিং পয়েন্ট নম্বর। C++ প্রোগ্রামিং ল্যাঙ্গুয়েজ-এ একটি ফ্লোটের সাইজ ৩২ বিট। এবং কিছু ফ্লোটিং পয়েন্ট ম্যানিপুলেশন ফাংশন আছে যা ফ্লোটিং-পয়েন্ট নম্বর গুলোর ওপর কাজ করে। এখানে আমরা কিছু ফ্লোটিং-পয়েন্ট ম্যানিপুলেশন ফাংশন পরিচয় করাচ্ছি।
fmod()
ফ্লোটস ওপর কাজ করার fmod() ফাংশন পাস করা আর্গুমেন্ট গুলোর ভাগশেষ রিটার্ন করবে।
উদাহরণ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float a, b, rem;
a = 23.4;
b = 4.1;
rem = fmod(a,b);
cout<<"The value of fmod( "<<a<<" , "<<b<<" ) = "<<rem;
}
আউটপুট
The value of fmod( 23.4 , 4.1 ) = 2.9
remainder()
remainder() ফাংশনটি fmod ফাংশনের মতোই কাজ করে। এবং মান দুটির মধ্যে ভাগশেষ রিটার্ন করে। এই মেথডটি সংখ্যাগত দৃষ্টিতে ন্যূনতম সম্ভাব্য ভাগশেষ রিটার্ন করে। এটি নেগেটিভও হতে পারে।
উদাহরণ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float a, b, rem;
a = 23.4;
b = 4.1;
rem = remainder(a,b);
cout<<"The value of remainder( "<<a<<" , "<<b<<" ) = "<<rem;
}
আউটপুট
The value of remainder( 23.4 , 4.1 ) = -1.2
remquo()
এই মেথডটি পাস করা দুটি ভ্যালুর কোশিয়েন্ট এবং রিমেইনডার রিটার্ন করে। এটিতে একটি ভেরিয়েবলের রেফারেন্সও দরকার যা কোশিয়েন্টের মান ধারণ করবে। সুতরাং, এই মেথডটি রিমেইনডার রিটার্ন করবে remainder ফাংশনের মতো এবং কোশিয়েন্টের রেফারেন্স।
উদাহরণ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
float a, b, rem;
int quo;
a = 23.4;
b = 4.1;
rem = remquo(a,b,&quo);
cout<<a<<" and "<<b<<" passed to the remquo() function gives the following output\n";
cout<<"The remainder is "<<rem<<endl;
cout<<"The quotient is "<<quo;
}
আউটপুট
23.4 and 4.1 pass to the the remque() function gives the following output The reminder is -1.2 The quotient is 6
copysign()
C-এর copysign ফাংশন একটি ভেরিয়েবল রিটার্ন করে অন্য ভেরিয়েবলের সাইন দিয়ে। রিটার্ন করা ভেরিয়েবলের ম্যানিটিউড হবে প্রথম ভেরিয়েবলটির এবং সাইন হবে দ্বিতীয় ভেরিয়েবলটির।
উদাহরণ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b;
a = 9.6;
b = -3.5;
cout<<"copysign function with inputs "<<a<<" and "<<b<<" is "<<copysign(a,b);
}
আউটপুট
Copysign function with inputs 9.6 and -3.5 is -9.6
fmin()
fmin ফাংশন যেমন তার নাম থেকে বোঝা যাচ্ছে ফাংশনের দুটি আর্গুমেন্টের ন্যূনতম মান রিটার্ন করে। রিটার্ন টাইপ হল ফ্লোট।
উদাহরণ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b;
a = 43.5;
b = 21.2;
cout << "The smallest of "<<a<<" and "<<b<<" is "; cout << fmin(a,b)<<endl;
}
আউটপুট
The smallest of 43.5 and 21.2 is 21.2
fmax()
fmax ফাংশন একটি C প্রোগ্রামিং ফাংশন যা আর্গুমেন্ট হিসেবে দেওয়া দুটি নম্বরের মধ্যে সবচেয়ে বড় নম্বরটি রিটার্ন করে।
উদাহরণ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b;
a = 43.5;
b = 21.2;
cout << "The largest of "<<a<<" and "<<b<<" is "; cout << fmax(a,b)<<endl;
}
আউটপুট
The largest of 43.5 and 21.2 is 43.5
fdim()
C প্রোগ্রামিং ল্যাঙ্গুয়েজের fdim() ফাংশন আর্গুমেন্ট হিসেবে পাঠানো দুটি নম্বরের অ্যাবসোলিউট ডিফারেন্স রিটার্ন করে।
উদাহরণ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b;
a = 43.5;
b = 21.2;
cout << "The absolute difference of "<<a<<" and "<<b<<" is";
cout << fdim(a,b)<<endl;
}
আউটপুট
The absolute difference of 43.5 and 21.2 is 22.3
fma()
fma() ফাংশন C-র, আর্গুমেন্ট হিসেবে দেওয়া মান গুলোর গুণফল রিটার্ন করে। ফাংশনটি একটি ফ্লোট রিটার্ন করে এবং তিনটি ফ্লোটিং আর্গুমেন্ট গ্রহণ করে।
উদাহরণ
#include <iostream>
#include <cmath>
using namespace std;
int main() {
double a, b, c;
a = 3.5;
b = 2.4;
c = 7.2;
cout << "The multiplication of "<<a<<" , "<<b<<" and "<<c<<" is ";
cout << fma(a,b,c)<<endl;
}
আউটপুট
The multiplication of 3.5 , 2.4 and 7.2 is 15.6
এই সকল ফাংশন হল ফ্লোটিং-পয়েন্ট নম্বর গুলোর ওপর অপারেশন করা ফাংশন গুলো। এই ফাংশন গুলো cmath লাইব্রেরিতে ডিফাইন করা আছে।