• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 456
  • Last Modified:

How To Convert a 4 Byte Number In String Form To a Numeric Array

I think I previously posted this in the wrong zone. Sorry for the inconvenience.

Question:

I have 10 digit decimal numbers (4 bytes each) in string form that I need to convert to numeric form so that I can place them in an an array.

My array is declared as:

___________________________________________________________

type
TModemSigArray  = array[0..1499] of dword;

var
ModemSigArray: TModemStatArray;

______________________________________________________

The numbers in string form arrive by an enet port and all are 10 digits long. When I convert using "StrToInt" and place it in the array, the number that is represented in the array is different (smaller) than the original.

My code:

E := StrToInt(1234567890);              //Convert from string to integer
ModemSigArray[IDCounter] := E;      //Load array


The numbers have not exceeded the Integer limitaion of 2,147,483,648. However I have tried using  StrToInt64, converting to Hex (because of the 64 bit limitation), to no avail.

0
jsmitter
Asked:
jsmitter
1 Solution
 
jimyXCommented:
Would you please post the code you used, as the following code works:

type
TModemSigArray  = array[0..1499] of dword;

procedure TForm1.Button1Click(Sender: TObject);
var
  E:integer;
  ModemSigArray: TModemSigArray;
begin
  E := StrToInt('1234567890');
  ModemSigArray[0] := E;
  showmessage(inttostr(ModemSigArray[0]));
end;

Open in new window



>   10 digit decimal numbers...I need to convert to numeric

If your numbers are decimal, you use Float instead of Int.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now