about summary refs log tree commit diff stats
path: root/src/utils
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-06-10 01:56:08 +0200
committerbptato <nincsnevem662@gmail.com>2023-06-10 01:56:08 +0200
commit1bd7651f70ef7ba7a3506f12d4c9f4d7735180f5 (patch)
treef05b9750153e18e2d3856869e7df4a2ea69f58ea /src/utils
parente8e9d27c9496ee5a0679197272d5ca8d1b5a2953 (diff)
downloadchawan-1bd7651f70ef7ba7a3506f12d4c9f4d7735180f5.tar.gz
approximateANSIColor: fix possible underflow
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/chamath.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/utils/chamath.nim b/src/utils/chamath.nim
new file mode 100644
index 00000000..579b7b69
--- /dev/null
+++ b/src/utils/chamath.nim
@@ -0,0 +1,4 @@
+func absSub*(a, b: SomeUnsignedInt): auto {.inline.} =
+  if a > b:
+    return a - b
+  return b - a
n130' href='#n130'>130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192