ULong2Long - Reinterpret an unsigned 32 bit integer as signed

Top  Previous  Next

Syntax

 

<nLong> := ULong2Long( <nULong> )

 

Parameters

 

<nULong>

 

ULONG value to be converted to LONG value. Values outside the allowed range will result in unpredictable return values.        

 

Return value

 

The LONG value that results if the bits in <nULong> are interpreted as signed.

 

Description

 

ULong2Long converts an unsigned 32 bit value into a signed 32 bit value. In C a 32bit value can be interpreted in different ways. This interpretation is defined by the type. For example the binary value 11111111 11111111 11111111 11111111 could be interpreted as +4294967295 (ULONG) or as -1 (LONG).

 

So what this function actually does is reinterpret the bit pattern of the ULONG <nULong> as a LONG.

 

Classification

 

Core

 

Category

 

Type Conversion

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

See also

 

Long2ULong

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

LOCAL ul, l

 

* assign the biggest possible unsigned long value

ul := 0xFFFFFFFF

 

* reinterpret the bits as long value

l := ULong2Long(ul)

 

* Display the result (should be -1)

? l

 

RETURN NIL