-
-
Notifications
You must be signed in to change notification settings - Fork 239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Number IsInt, IsUint, IsFloat, IsNan #155
Comments
I'd like to give this a shot. Can I pick this up? |
Sure, thanks! |
@deepto98 Hi, do you still have plans on this? |
Unassigning, so that someone could pick this up. |
@gavv, before I continue, could you check the WIP PR and see whether the solution is fine? I haven't finished
|
@fahimbagar thanks for taking up this. Will reply shortly. |
Hi, here are some thoughts.
|
Noted, thanks for the advice, @gavv. I'll adjust the PR then. |
I think for floats it's ok to limit allowed values to 32 and 64, at least for now. After implementing big.Float we can revise it. No need to wait for #191, I guess it will take time until it's ready. |
Landed! |
Implement new
Number
assertions:IsInt
- succeeds if number is signed or unsigned integer (does not have fractional part)IsUint
- succeeds if number is unsigned integer (does not have fractional part and is >= 0)IsFloat
- succeeds if number is not integer (have fractional part, is opposite toIsInt
)IsNan
- succeeds if number is NaNEach of them, except
IsNan
, should have optional argumentbits
which defines maximum allowed bitness for the number, e.g.IsInt(32)
means that the number should fit in 32-bit signed integer. SeeString.AsNumber
for en example of optional argument.For every assertion, also add negative version (
NotInt
,NotUint
, etc).Each assertion should have documentation comment with example and be covered by unit tests. Don't forget to cover corner cases like NaN, inf, etc.
The text was updated successfully, but these errors were encountered: