?
Solved

Base256 to int

Posted on 2006-10-24
8
Medium Priority
?
623 Views
Last Modified: 2008-02-01
Does anybody know how to convert a string (base 256 number) to integer?
0
Comment
Question by:TiborKi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 28

Accepted Solution

by:
2266180 earned 500 total points
ID: 17796908
0
 
LVL 46

Expert Comment

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

Author Comment

by:TiborKi
ID: 17798517
the string is 4 bytes
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 46

Expert Comment

by:aikimark
ID: 17798626
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
ID: 17798790
well, it must be fast...
0
 
LVL 46

Assisted Solution

by:aikimark
aikimark earned 500 total points
ID: 17798999
"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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

765 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