Short2UShort - Interpret a signed 16 bit integer as unsigned

Top 

Syntax

 

<nUShort> := Short2UShort( <nShort> )

 

Parameters

 

<nShort>

 

SHORT value whose bits are to be reinterpreted as USHORT value.

 

Return value

 

The USHORT value that results if the bits in <nShort> are interpreted as unsigned.

 

Description

 

Short2UShort converts (actually reinterprets) a signed 16 bit value into an unsigned 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

 

UShort2Short

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

LOCAL i, ui

 

i := -1

 

* reinterpret the bits as a signed short value

ui := Short2UShort(i)

 

* Display the result (should be 65535)

? ui

 

RETURN NIL