Class NumberUtils
java.lang.Object
org.checkerframework.common.value.util.NumberUtils
Utility routines for manipulating numbers.
-
Method Summary
Modifier and TypeMethodDescriptioncastNumbers
(TypeMirror type, boolean isUnsigned, List<? extends Number> numbers) Converts aList<A>
to aList<B>
, where A and B are numeric types.castNumbers
(TypeMirror type, List<? extends Number> numbers) Converts aList<A>
to aList<B>
, where A and B are numeric types.static Range
castRange
(TypeMirror type, Range range) Return a range that restricts the given range to the given type.
-
Method Details
-
castNumbers
Converts aList<A>
to aList<B>
, where A and B are numeric types.- Parameters:
type
- the type to cast tonumbers
- the numbers to cast to the given type- Returns:
- a list of numbers of the given type
-
castNumbers
public static List<? extends Number> castNumbers(TypeMirror type, boolean isUnsigned, List<? extends Number> numbers) Converts aList<A>
to aList<B>
, where A and B are numeric types.- Parameters:
type
- the type to cast toisUnsigned
- if true, treattype
as unsignednumbers
- the numbers to cast to the given type- Returns:
- a list of numbers of the given type
-
castRange
Return a range that restricts the given range to the given type. That is, return the range resulting from casting a value with the given range.- Parameters:
type
- the type for the cast; the result will be within itrange
- the original range; the result will be within it- Returns:
- the intersection of the given range and the possible values of the given type
-