Files

33 lines
1.4 KiB
Markdown

---
title: "Needs repeating: You can always perform a signed integer range test with a single comparison."
type: archive
source: twitter
source_url: "https://x.com/EricLengyel/status/867967467770920960"
author: "Eric Lengyel"
handle: EricLengyel
post_id: "867967467770920960"
date: 2017-05-26
archived: 2026-08-27
draft: false
tags:
- archive
- twitter
- EricLengyel
description: "Needs repeating: You can always perform a signed integer range test with a single comparison."
in_reply_to: ""
---
## Source
- URL: https://x.com/EricLengyel/status/867967467770920960
- Author: Eric Lengyel (@EricLengyel)
- Posted: 2017-05-26 04:55:45
## Thread
**1/** **@EricLengyel** ^867967467770920960
Needs repeating: You can always perform a signed integer range test with a single comparison. unsigned(x - lo) <= unsigned(hi - lo)
Branches: [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed/2017-05-26-vaughncato-shouldnt-that-be-unsigned-x-unsigned-lo-unsigned]], [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed/2017-05-26-vaughncato-otherwise-ub-if-hi-int-max-and-lo-int-min]], [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed/2017-05-26-noop_dev-yeah-this-is-one-of-the-things-coworkers-hate-me]], [[archive/threads/EricLengyel/2017-05-26-needs-repeating-you-can-always-perform-a-signed/2017-05-27-sreekotay-one-of-my-favs-and-special-cases-possible-for]]