MathCompare.less_bit: def of stelliferous@0.0.2.0 Import: import stelliferous@0.0.2.0/math_compare.bend as MathCompare Lines 15-25 of stelliferous@0.0.2.0/math_compare.bend: https://jend.leeeet.dev/read.txt?path=stelliferous@0.0.2.0/math_compare.bend&start_line=15&end_line=25 import Base # Magnitudes fit in 31 bits, so the top bit of their difference is the # unsigned comparison. Reverse it for negatives and handle opposite signs. def less_bit(+left: U32,+right: U32) -> U32: +a = U32.and(left,2147483647) +b = U32.and(right,2147483647) +negative = U32.shrn(left,31n) +different = U32.shrn(U32.xor(left,right),31n) +below = U32.shrn((a - b : U32),31n) +above = U32.shrn((b - a : U32),31n) +same = U32.xor(below,U32.and(negative,U32.xor(below,above))) U32.and(U32.xor(same,U32.and(different,U32.xor(same,negative))),nonzero(U32.or(a,b))) Uses (7): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.or https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.shrn https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.xor https://jend.leeeet.dev/definition.txt?path=stelliferous@0.0.2.0/math_compare.bend&name=nonzero