Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LongInt problem

Status
Not open for further replies.

Stretchwickster

Programmer
Apr 30, 2001
1,746
GB
I need to find out the last digit in a 10-digit LongInt variable. Has anyone got any ideas on how to achieve this?

e.g. 2147287045 - I need to be able to access just the '5' (the last digit)

Is it possible to cast it into a String? Or do some mathematical function on it to get that final digit?

Your help would be much appreciated :)
 
Obviously you only need to do the IntToStr if you want the digit as a string.
 
This one is Basic Pascal...

if

x = 2147287045;

then

y := x MOD 10; { y will equal 5 }

so

s := inttostr(y); { s will be a string containing "5")

or

c := chr(y + ord('0')); { c will be a char containing "5}

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top