Anyone know if Pi serial numbers are case sensitive?
For a project I'm working on I need to compare two serial numbers but I have no idea whether letter case is important. I'm inclined to go with no as they look like a text representation of hex digits but could someone on the inside confirm (or deny) this please.
- thagrol
- Posts: 4031
- Joined: Fri Jan 13, 2012 4:41 pm
- Location: Darkest Somerset, UK
- Contact: Website
Question about Pi serial numbers
Arguing with strangers on the internet since 1993.
-
- Posts: 13979
- Joined: Fri Mar 09, 2012 7:36 pm
- Location: Vallejo, CA (US)
Re: Question about Pi serial numbers
The serial number is a random 32-bit number. If you're seeing what looks like text, then it's probably being shown in hexadecimal. If some of your data is in lower- or mixed-case and you want to get reliable comparison, then do a bit-wise logical OR against spaces and then all the alpha characters will be upper case. FYI...this works in both ASCII and EBCDIC.
- DougieLawson
- Posts: 40530
- Joined: Sun Jun 16, 2013 11:19 pm
- Location: A small cave in deepest darkest Basingstoke, UK
- Contact: Website Twitter
Re: Question about Pi serial numbers
Hex numbers are not usually case sensitive. Convert it to an unsigned integer compare then convert back.
Any language using left-hand whitespace for syntax is ridiculous
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
Any DMs sent on Twitter will be answered next month.
Fake doctors - are all on my foes list.
Any requirement to use a crystal ball or mind reading will result in me ignoring your question.
- thagrol
- Posts: 4031
- Joined: Fri Jan 13, 2012 4:41 pm
- Location: Darkest Somerset, UK
- Contact: Website
Re: Question about Pi serial numbers
Thanks guys, you've confirmed what I was thinking.
Arguing with strangers on the internet since 1993.
- Paul Webster
- Posts: 833
- Joined: Sat Jul 30, 2011 4:49 am
- Location: London, UK
- Contact: Twitter
Re: Question about Pi serial numbers
Converting to integer and comparing will also remove any potential issue with leading zeroes being present or not - i.e. not only a potential case issue.
- thagrol
- Posts: 4031
- Joined: Fri Jan 13, 2012 4:41 pm
- Location: Darkest Somerset, UK
- Contact: Website
Re: Question about Pi serial numbers
Yeah, that's what I went with.
If anyone's interested the relevent project is here: https://github.com/thagrol/usb-gadget
If anyone's interested the relevent project is here: https://github.com/thagrol/usb-gadget
Arguing with strangers on the internet since 1993.