7

I'm wondering if it's possible to define a custom data type which can only take a value between -3.1415926535897932 and 3.1415926535897931.

The idea is that a value below or above the range would automatically "wrap-around", eliminating the need to write code to do the conversion and also eliminating the possibility of error somewhere.

4

1 回答 1

0

对的,这是可能的。在设置值的方法中,检查它是否超出限制,如果是,请执行您想要执行的任何操作以强制它在限制范围内。fmod 是一种不错的操作选择。

于 2013-06-28T15:05:59.290 回答