- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Also, the Java char type must be 2-byte Unicode. So, a zero character is stored as the number 48 decimal in a 2-byte integer.
The numbers 0 to 9 are the codes 48+n, n in [0..9]. The hex letters A to F are 65+(k-11), k in [11..15]. This is how any language converts digits to char encodings.
Admin
Except not all japanese (kanji) characters are included in original unicode 16-bit range. UTF-16 would work, using 2x16 bits. Mostly needed for names, as far as I know. My ex-girlfriend couldn't write her name correctly with 16-bit unicode, she had to write the "sound" instead.
Admin
Ummm... yeah.
Admin
I'm surprised nobody's commented on it, but my favorite part is:
I'm sure glad that comment is there, because otherwise who would have guessed that NUMBER_OF_HEXADECIMAL_CHARACTERS_PER_BYTE is supposed to represent the number of hexadecimal characters per byte?
Admin
Admin
It made incredibly sophisticated use of "sin()" and "tan()". And it was in AmigaBasic.
And my only excuse is that I was yound and innocent (just 16 y.o.) at that time. Well, I'm still kind of young... ;-)
Admin
not sure where sin and tan would come into simple integer maths..
usage: ToAnyBase(100, new char[] {'0', '1'}) // == "1100100"
you can give any alphabet you like, so you can encode numbers into the numeric alphabet 'NeRdLiNgEr' (which is actually base 10 so not a great example) as long as two characters don't repeat themselves - that would make the value impossible to decode back into an int... such validation should be added to the function but i CBF'd.
Admin
This person was obviously educated in the USA.
Admin
In c the obvious one-linear: ((a?"DF9B":"5713")+!!c)[2*!b]-!d
Admin
In some archaic architectures (eg. pdp10 and 704) a byte has 9 bits. but no one uses thoes archetectures anymore.
Admin
It's not that I object to being paid per line, which in a sense is how this is working out.
It's just that, under the circumstances, I'd prefer the lines in question to be coke. And I don't even like the damn stuff.
Admin
print [0..9,a..f]->[$bit18+$bit24+$bit32$bit4];
Admin
Gah... why do all of you cling to bit1 through bit4? They were extracted from the number already in their correct positions.
headdesk
If you want to avoid the cycle cost of sprintf() (and I've been in such situations believe it or not), why not something like this to convert a 32-bit number into a hex string?
Admin
I think I wrote a lexical analyzer in that same manner for a compilers class back in college....I quickly learned the error of my ways.
Admin
writing one line of code that actually results in executing a thousand lines of code is no better than the op's solution...
Admin
"without having to pack and unpack larger data structures"
you clearly have never looked at the asm output of the majority microcontroller C compilers
Admin
Why separate the bits into individual bools just to recombine them? Try this:
const char *nibbles = "0123456789ABCDEF"; char firstChar = nibbles[byteValue & 0xF]; char secondChar = nibbles[(byteValue>>4) & 0xF];
Then just go through each byte as needed
Admin
Admin
If you want speed, you turn on optimization on the compiler. If you don't turn on optimization and worry about speed, you're wasting your time doing things the compiler could be doing.
Admin
pharmacie en ligne fiable https://kamagraenligne.shop/# pharmacie en ligne