MCPcopy Create free account
hub / github.com/NVIDIAGameWorks/Falcor / compare

Method compare

external/include/fast_float/fast_float.h:2063–2080  ·  view source on GitHub ↗

compare two big integers, returning the large value. assumes both are normalized. if the return value is negative, other is larger, if the return value is positive, this is larger, otherwise they are equal. the limbs are stored in little-endian order, so we must compare the limbs in ever order.

Source from the content-addressed store, hash-verified

2061 // the limbs are stored in little-endian order, so we
2062 // must compare the limbs in ever order.
2063 int compare(const bigint& other) const noexcept {
2064 if (vec.len() > other.vec.len()) {
2065 return 1;
2066 } else if (vec.len() < other.vec.len()) {
2067 return -1;
2068 } else {
2069 for (size_t index = vec.len(); index > 0; index--) {
2070 limb xi = vec[index - 1];
2071 limb yi = other.vec[index - 1];
2072 if (xi > yi) {
2073 return 1;
2074 } else if (xi < yi) {
2075 return -1;
2076 }
2077 }
2078 return 0;
2079 }
2080 }
2081
2082 // shift left each limb n bits, carrying over to the new limb
2083 // returns true if we were able to shift all the digits.

Callers 1

negative_digit_compFunction · 0.45

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected