I like decimal
in many of my C# programs and I want to try it in other C languages.
I wrote this code in C#:
using System;
decimal get_pi();
int main() {
Console.WriteLine("Give a number ranging from 1-100: ");
decimal num = Console.ReadLine();
Console.Write("Algebraic Equivalent: ");
if (num >= get_pi()) {
Console.WriteLine("π");
} else {
Console.WriteLine(num);
}
// Currently updating the program for giving algebraic equivalents
}
And I want to rewrite it in C++.
I realized that in both C and C++, they have no exact equivalent to the decimal
type, and best you can use is double
, but the fact that there's actually a supported decimal
type in C (based on Is there a C equivalent of C#'s decimal type?), it got me curious if there is also an equivalent in C++.
Is there any C# decimal
type equivalent in C++ or is double
the best choice instead?