Object
|
+---DShort
The Short class implements a number of methods for storing and manipulating short numbers.
#include <stdio.h>
#include "ofc/DShort.h"
int main(int argc, char *agv[])
{
DShort *s1 = [DShort alloc];
DShort *s2 = [DShort new ];
DText *str;
[s1 init :-70]; // Init with a number
printf("Short1 has value:%d.\n", [s1 get]); // Get value from object
[s2 set :140]; // Set with a number
str = [s2 toText];
printf("Short2 has value:%s as string.\n", [str cstring]); // Convert value to string
[str free];
if ([s1 compare :s2] == 0) // Compare shorts
printf("Short1 and short2 are equal.\n");
else if ([s1 compare :s2] < 0)
printf("Short1 is smaller than short2.\n");
else
printf("Short1 is greater than short2.\n");
// Conversion big- and little-endian
printf("Short1 as little-endian (%d) and as big-endian (%d).\n", [s1 toLittleEndian], [s2 toBigEndian]);
[s1 free]; // Cleanup
[s2 free];
return 0;
}