Solved

Base256 to int

Posted on 2006-10-24
8
599 Views
Last Modified: 2008-02-01
Does anybody know how to convert a string (base 256 number) to integer?
0
Comment
Question by:TiborKi
  • 3
  • 2
8 Comments
 
LVL 28

Accepted Solution

by:
ciuly earned 125 total points
Comment Utility
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
How big is the string?
The ciuly link is probably the easiest solution.
0
 
LVL 1

Author Comment

by:TiborKi
Comment Utility
the string is 4 bytes
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 45

Expert Comment

by:aikimark
Comment Utility
The only problem you are likely to encounter is signed versus unsigned integer values.  If the high-order bit of the high-order byte = 1 then a signed integer will be negative.

Is this a performance critical function or do you simply need to know how it can be done?
0
 
LVL 1

Author Comment

by:TiborKi
Comment Utility
well, it must be fast...
0
 
LVL 45

Assisted Solution

by:aikimark
aikimark earned 125 total points
Comment Utility
"fast" is relative.  The best course of action will be to try the ciuly linked solution and determine if it suits your needs as far as functionality and speed.  If it doesn't, then ask us for more help.

===================================
For future readers, there are several approaches available to do this conversion.
* character->ord add and shiftLeft 8 (three statement pairs followed by simple add)
* similar to above, but using For iteration construct
* Delphi Copy function or API call to copy bytes directly into integer variable.  May require additional ntohl API call to reverse the byte order to accomodate Little-endian Windows environment.  This solution can get really tricky, depending on the nature of the 'string variable'.  Due to complexity, this should be solution approach of last resort.
* ASM solution (see the FastCode project)
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now