flat assembler
Message board for the users of flat assembler.

Index > Heap > Efficient int to string

Author
Thread Post new topic Reply to topic
mattst88



Joined: 12 May 2006
Posts: 260
Location: South Carolina
mattst88
I've got a function
Code:
void Append (const String &pString)    

and I've got a single digit number (stored as int). I need to append() the int.

What's the most efficient way to do this? Looking for a balance of clarity and efficiency.

I've got the following code
Code:
char character[2];
sprintf(character, "%d", input_int);
Append((const char *)&character);    


I'd rather stick with C/C++ but if assembly would be that much better, I'll consider it.

Thanks.

_________________
My x86 Instruction Reference -- includes SSE, SSE2, SSE3, SSSE3, SSE4 instructions.
Assembly Programmer's Journal
Post 16 Dec 2007, 23:45
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Let's clarify something, the following code is conscientiously equivalent?

Code:
char character[2];
character[0] = (char) input_int + '0'; character[1] = '\0';
Append((const char *)&character);    


If it is the case then you are just looking for a fast strlen. There was some examples posted by Madis and maybe other people that checks for NULL four bytes concurrently. If you have not success at all with the forum's search engine then I hope Madis will point out something around this Smile
Post 17 Dec 2007, 00:09
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Found http://board.flatassembler.net/topic.php?t=2628 . Seems that actually revolution have most of the credit Razz
Post 17 Dec 2007, 00:22
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.