Recent

Author Topic: Data type question  (Read 2056 times)

justnewbie

  • Sr. Member
  • ****
  • Posts: 292
Data type question
« on: April 06, 2018, 02:16:15 pm »
Hi!
I have a StringGrid and its cells contain numbers.
These numbers are bigger than the LongInt range (>2147483647).
But, I have to use them for some calculating and need to convert them from string (StringGrid cells) by using StrToInt.
My problem is that StrToInt returns a LongInt, but my numbers are LongWord.
How can it be resolved?
« Last Edit: April 06, 2018, 02:19:46 pm by justnewbie »

Blaazen

  • Hero Member
  • *****
  • Posts: 3239
  • POKE 54296,15
    • Eye-Candy Controls
Re: Data type question
« Reply #1 on: April 06, 2018, 02:21:35 pm »
There are functions StrToInt64() or TryStrToInt64().
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

justnewbie

  • Sr. Member
  • ****
  • Posts: 292
Re: Data type question
« Reply #2 on: April 06, 2018, 02:23:18 pm »
There are functions StrToInt64() or TryStrToInt64().
Thank you! I hoped it, but the "See also" section doesn't show these functions at https://www.freepascal.org/docs-html/rtl/sysutils/strtoint.html

Handoko

  • Hero Member
  • *****
  • Posts: 5154
  • My goal: build my own game engine using Lazarus
Re: Data type question
« Reply #3 on: April 06, 2018, 02:26:50 pm »
You can also try TStringHelper.ToInt64 and TInt64Helper.ToString:
https://www.freepascal.org/docs-html/rtl/sysutils/tstringhelper.toint64.html
https://www.freepascal.org/docs-html/rtl/sysutils/tint64helper.tostring.html

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.   S   : string;
  4.   I64 : Int64;
  5. begin
  6.   S   := '123456789012';
  7.   I64 := S.ToInt64;
  8.   ShowMessage(I64.ToString);
  9. end;

justnewbie

  • Sr. Member
  • ****
  • Posts: 292
Re: Data type question
« Reply #4 on: April 06, 2018, 02:32:00 pm »
Perfect, works! Thank you guys!

 

TinyPortal © 2005-2018