mirror of
https://github.com/vlang/v.git
synced 2025-09-18 11:56:57 -04:00
math.unsigned: add uint256_new() function and tests (#24837)
This commit is contained in:
parent
3eb04e346c
commit
c989f9bb78
@ -170,3 +170,7 @@ fn test_separators() {
|
||||
assert with == without
|
||||
}
|
||||
}
|
||||
|
||||
fn test_new() {
|
||||
assert unsigned.uint128_new(max_u64, max_u64) == unsigned.uint128_max
|
||||
}
|
||||
|
@ -22,6 +22,11 @@ pub fn uint256_from_64(v u64) Uint256 {
|
||||
return uint256_from_128(uint128_from_64(v))
|
||||
}
|
||||
|
||||
// uint256_new creates new Uint256 with given `lo` and `hi`
|
||||
pub fn uint256_new(lo Uint128, hi Uint128) Uint256 {
|
||||
return Uint256{lo, hi}
|
||||
}
|
||||
|
||||
// is_zero checks if specified Uint256 is zero
|
||||
pub fn (u Uint256) is_zero() bool {
|
||||
return u.lo.is_zero() && u.hi.is_zero()
|
||||
|
@ -276,3 +276,7 @@ fn test_separators() {
|
||||
assert with == without
|
||||
}
|
||||
}
|
||||
|
||||
fn test_new() {
|
||||
assert unsigned.uint256_new(unsigned.uint128_max, unsigned.uint128_max) == unsigned.uint256_max
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user