UShort2Short - Interpret an unsigned 16 bit integer as signed

Top  Previous  Next

Syntax

 

<nShort> := UShort2Short( <nUShort> )

 

Parameters

 

<nUShort>

 

USHORT value to be reinterpreted as SHORT value.

 

Return value

 

The SHORT value that results if the bits in <nUShort> are interpreted as signed.

 

Description

 

UShort2Short "converts" (actually reinterprets) an unsigned 16 bit value into a signed 16 bit value. In C a 16bit value can be interpreted in different ways. This interpretation is defined by the type. For example the binary value 11111111 11111111 could be interpreted as +65535 (USHORT) or as -1 (SHORT).

 

Classification

 

Core

 

Category

 

Type Conversion

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

See also

 

Short2UShort

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

LOCAL ui, i

 

ui := 65535

 

* reinterpret the bits as an unsigned int value

i := UShort2Short(ui)

 

* Display the result (should be -1)

? i

 

RETURN NIL