How to determine a number with a valid -PI range for PI?

I am wondering if it is possible to define a custom data type that can only take a value between -3.1415926535897932 and 3.1415926535897931.

The idea is that a value below or above the range automatically β€œwraps around,” eliminating the need to write code for conversion, and also eliminating the possibility of error somewhere.

+7
source share
1 answer

Yes it is possible. In the method that sets the value check to make sure that it is out of limit, and if so, do whatever operation you want to do to make it fall within. fmod is one good choice to work with.

0
source

All Articles