Can’t you just search through and remove all the non-digit characters? (Excel user here)
Packing a string of digits into an integer quickly
11–19 of 19 posts
Re: Packing a string of digits into an integer quickly
#12Re: Packing a string of digits into an integer quickly
#13It was a fairly common thing to do very similar operations on Apple ][ computers. 6502 had a BCD (binary coded decimal) mode; basically when in BCD mode arithmetic operators carried at 0x9 rather than 0xF, and operations worked nibble-wise rather than byte-wise. So it was common to represent 2 digits in one bye regardless of hex vs decimal. I actually have been thinking about this lately because of the other half of…
100/256 seems very tolerable efficiency-wise.
Re: Packing a string of digits into an integer quickly
#14Re: Packing a string of digits into an integer quickly
#15Anyone know an efficient way of zipping/interleaving two bitmasks on Intel? Assume both bitmasks are in their own mask registers, and the top halves and bottom halves can be zipped into separate output registers. My current solution uses the pdep instruction.
Here's my solution, which also uses pdep/pext
Re: Packing a string of digits into an integer quickly
#16Can’t you just search through and remove all the non-digit characters? (Excel user here)
The time scale between OP's code and yours is about the same as the timescale between yours and mine :)
Re: Packing a string of digits into an integer quickly
#17Re: Packing a string of digits into an integer quickly
#18How often these days strings are arrays of characters terminated with '\0' instead of UTF16?
Re: Packing a string of digits into an integer quickly
#19Earlier quoted context omitted.
No, he says that the strings can contain spaces and other characters but that he wants them ordered (only) by the decimal digits in them. I don't see how this can work either.
Looking at the code, it seems like it expects a string of the form "dddddddd?dddddd" where the '?' is any ascii character, and the code assumes the rest of the characters are ascii digits. Specifically the line: `part2 = _pext_u64(part2, 0x0f000f0f0f0f0f0f);` seems to mask out that character.