Page 1 of 1

percent of the total file size (quad) ?

Posted: Tue Jun 08, 2010 8:48 am
by bingo
no problem with long:

Code: Select all

size.l = 99999
i.l = 999
percent.f

percent = (i/size) * 100
Debug percent  
but how can i use this with BIG quads ? :roll:

Code: Select all

size.q = 9999999999999999999
i.q = 999999999
percent.f
  
percent = (i/size) * 100
Debug percent ;?

Re: percent of the total file size (quad) ?

Posted: Tue Jun 08, 2010 9:16 am
by blueznl
Does this help?

Code: Select all

percent.q = 100 * i / size
or perhaps...

Code: Select all

percent.d = 100 * i / size

Re: percent of the total file size (quad) ?

Posted: Tue Jun 08, 2010 9:30 am
by bingo
no.

http://msdn.microsoft.com/en-us/library ... S.85).aspx

An application can use this information to display a progress bar that shows the total number of bytes copied as a percent of the total file size.

but it is not useful for big files.

Re: percent of the total file size (quad) ?

Posted: Tue Jun 08, 2010 10:44 am
by Trond
Your main problem is that the value you put into size is larger than what a quad can store, so it overflows.

Max quad: +9223372036854775807
Your num: +9999999999999999999

Re: percent of the total file size (quad) ?

Posted: Tue Jun 08, 2010 4:26 pm
by Fluid Byte
There are no files that big. Why do you need this?

Re: percent of the total file size (quad) ?

Posted: Tue Jun 08, 2010 11:06 pm
by blueznl
Bingo, turn everything into .d's and it will work. Indeed the question is: are you going out of bounds on quads?

Re: percent of the total file size (quad) ?

Posted: Wed Jun 09, 2010 6:44 am
by bingo
thanks.

it works with:

Code: Select all

TotalFileSize.q
tf.d = TotalFileSize

Re: percent of the total file size (quad) ?

Posted: Wed Jun 09, 2010 7:10 am
by blueznl
You may want to read up a little on variable types and (how purebasic does) type conversion...

http://www.xs4all.nl/~bluez/purebasic/p ... _variables
http://www.xs4all.nl/~bluez/purebasic/p ... evaluation