MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / compare

Function compare

model/model.go:52–69  ·  view source on GitHub ↗

compare compares two *big.Int values based on the provided condition (e.g., >, <, ==). Returns true if the condition holds, otherwise false.

(value *big.Int, condition string, compareTo *big.Int)

Source from the content-addressed store, hash-verified

50// compare compares two *big.Int values based on the provided condition (e.g., >, <, ==).
51// Returns true if the condition holds, otherwise false.
52func compare(value *big.Int, condition string, compareTo *big.Int) bool {
53 cmp := value.Cmp(compareTo) // Compare value and compareTo.
54 switch condition {
55 case ">":
56 return cmp > 0
57 case "<":
58 return cmp < 0
59 case ">=":
60 return cmp >= 0
61 case "<=":
62 return cmp <= 0
63 case "!=":
64 return cmp != 0
65 case "==":
66 return cmp == 0
67 }
68 return false
69}
70
71// InitializeBalanceFields initializes all the fields of the Balance struct that might be nil.
72// This ensures that all balance-related fields have valid *big.Int values for further operations.

Callers 2

CheckConditionMethod · 0.85
TestCompareFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestCompareFunction · 0.68