Page 1 of 1

UNIT64 - what is it?

Posted: Fri Aug 01, 2008 1:08 pm
by SFSxOI
I've run into some stuff in the new API's for Vista I don't know how to represent in PureBasic. One of them is UNIT64.

What is UNIT64? How is it represented in PureBasic? Is UNIT64 a quad in PureBasic?

How would a constant something like this be represented:

Code: Select all

someconstant (0x00001ui64)
Simply like this?

Code: Select all

#someconstant = $00001

?????

Posted: Fri Aug 01, 2008 1:30 pm
by ts-soft
UNIT64? or UINT64?
UINT64 is a unsigned Quad, not available in PB, but you can use Quad, is
the same memory but not the same valuerange

Posted: Fri Aug 01, 2008 1:30 pm
by Progi1984
UNIT64 must be replaced by UINT64;

Yes, it's a quad;

Reference : http://www.purebasic.fr/english/viewtop ... ght=uint64

Posted: Fri Aug 01, 2008 2:02 pm
by SFSxOI
UNIT64, so that is a quad. Oki dokee then.

But what about the strange constant like: someconstant (0x00001ui64)

what is the ui64?

Thanks for your help :)

Posted: Fri Aug 01, 2008 4:33 pm
by Kale
SFSxOI wrote:what is the ui64?
The "i64" and "ui64" extensions are non-standard, Microsoft compiler specific extensions used for specifing 64bit integer constants.

Posted: Fri Aug 01, 2008 6:42 pm
by SFSxOI
Kale wrote:
SFSxOI wrote:what is the ui64?
The "i64" and "ui64" extensions are non-standard, Microsoft compiler specific extensions used for specifing 64bit integer constants.
well, crap....I was in the progress of converting the managment portion of the Windows Filtering Platform API for Vista and Server 2008, for use with PureBasic. Was going pretty smooth for a bit, had some basic functions working too, then I encountered the 'ui64' thing. So...if its microsoft compiler specific...well...just Great! :(

gotta find some way to work around it.


Thanks Folks :)

Posted: Sat Aug 02, 2008 2:40 am
by jack
SFSxOI I don't see the problem, 0x00001ui64 simply means that the hex value is a Quad.

Posted: Sat Aug 02, 2008 11:32 am
by Kale
jack wrote:SFSxOI I don't see the problem, 0x00001ui64 simply means that the hex value is a Quad.
The problem is it's unsigned. There is no problem storing a 64bit number but retrieving a meaningful value from the quad is a little tricky.

Posted: Tue Feb 03, 2009 9:01 pm
by SFSxOI
I know this thread is a bit old, but rather then starting a new one for the same subject...

I'm just getting back to working on the Windows Filtering Platform API for Vista, had put it aside for a while. I can't figure out how to get a useful value from the ui64 thing. Any ideas anyone?

Posted: Tue Feb 03, 2009 9:18 pm
by Kaeru Gaman
a problem only occurs when the highest bit is set.

then, PB will interpret it as negative value.

so, when you need to check a uint64 value, you could e.g. check for the highest bit with
If Val < 0

depending on the case you need it, you should get from the documentation if the highest bit could be set by any chance.

declaring a function to use a uint64 does not mean that every value passed will have the highest bit set...

Posted: Wed Feb 04, 2009 1:46 am
by pdwyer
shifting will work differently too, the sign bit doesn't shift with the rest of the value (I don't think, something like that)

Posted: Wed Feb 04, 2009 5:15 am
by Kaeru Gaman
with shifting via PB the signbit remains set, iirc.
but you can call the asm command for unsigned shift.

anyhow, checking for single bits doesn't know any difference in signed or unsigned,
so checking a 64bit Flag register will work without problems.

I think the approach to deal with this will strongly depend on the purpose of this uint64 value.

Posted: Wed Feb 04, 2009 6:01 am
by pdwyer
what is the ASM command for unsigned shifting? that would be handy

Posted: Wed Feb 04, 2009 2:45 pm
by Thalius
isnt the result of lpperformancecounter also a UINT64 ?

i found this on a quick google - maybe useful.

http://books.google.ch/books?id=avDkMnu ... 1-PA114,M1

Posted: Wed Feb 04, 2009 4:00 pm
by Kaeru Gaman
> what is the ASM command for unsigned shifting?

don't know by heart... read it in a topic here not long ago.


> isnt the result of lpperformancecounter also a UINT64 ?

for handling a counter, it is meaningless if you notate it signed or unsigned.
handling the overflow is almost the same.
tho I'm unsure right now, if an overflow of some 64bit counter even can occur within the next thousand years...