Recent

Author Topic: SOLVED-Divison of two numbers  (Read 2761 times)

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
SOLVED-Divison of two numbers
« on: December 16, 2012, 02:56:21 am »
Ok this is my problem
var
sizeMB: Integer;

lblSize.caption := fileSize('/home/technet/somFile'); // Size of file in bytes reported to 1146 in this case

ok so now i have the files size

sizeMB := StrToInt('1146') Div 1024;    // Devide file size by 1024

sizeMB := 1  //  I need it to = 1.119140625   just like if you was to devide those figures on a calculator

I have also tried

sizeMB := sizeMB / 1024; 


how can I achieve the results I need

Im sure this is a simple process but everything i  have tried is not working for me can some one point me in the right direction.

« Last Edit: December 16, 2012, 03:34:03 am by wjackson153 »
Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

Carver413

  • Full Member
  • ***
  • Posts: 119
Re: Divison of two numbers
« Reply #1 on: December 16, 2012, 03:12:42 am »
sizeMB must be a float not an integer

sizeMB:Single;
sizeMB := StrToInt('1146') / 1024;

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
Re: Divison of two numbers
« Reply #2 on: December 16, 2012, 03:31:23 am »


lblStatus.caption := IntToStr(filesize('/home/technet/Desktop/StartupInfo'));
sizeMB := StrToInt('1146') / 1024;
lblStatus.Caption := IntToStr(sizeMB);      // How can i get sizeMB into labels caption,

is there a sngToStr function lol 
Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
Re: SOLVED-Divison of two numbers
« Reply #3 on: December 16, 2012, 03:35:25 am »
Nevermind I figured it out

since single is a float type, it dawned on me i seen a floattostr()
I tried that and it worked :)

thanks for for pointing me in the right direction :)

Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

 

TinyPortal © 2005-2018