- Inherits from:
- Object
- Conforms to:
- DComparable, DDatable, DParsable, DTextable
- Declared in:
- DDouble.h
Object
|
+---DDouble
Class Description
The Double class implements a number of methods for storing and manipulating double numbers.
- Example:
#include <stdio.h>
#include "ofc/DDouble.h"
int main(int argc, char *argv[])
{
DDouble *db1 = [DDouble alloc];
DDouble *db2 = [DDouble new ];
DText *str;
[db1 init :7.0]; // Init with a value
[db2 set :14.0]; // Set with a value
str = [db1 toText];
printf("Double1 is:%.1f and \"%s\".\n", [db1 get], [str cstring]);
[str free];
if ([db1 compare :db2] == 0)
printf("Double1 is equal to double2.\n");
else
if ([db1 compare :db2] < 0)
printf("Double1 is smaller than double2.\n");
else
printf("Double1 is greater than double2.\n");
[db1 free]; // Cleanup
[db2 free];
return 0;
}
- Last modified:
- 24-Jul-2008 (DDouble.h)
Instance Variables
- private double _double
- Constructors
- - (DDouble *) init
- Initialise to number zero
- Returns:
- the object
- - (DDouble *) init :(double) number
- Initialise to a number
- Parameters:
- number - the number
- Returns:
- the object
- Member methods
- - (double) get
- Get the double
- Returns:
- the double number
- - (DDouble *) set :(double) number
- Set the double number
- Parameters:
- number - the double number
- Returns:
- the object
- Comparable protocol
- - (int) compare :(DDouble *) other
- Compare two double objects
- Parameters:
- other - the object to compare with
- Returns:
- the result of the comparison (-1,0,1)
- Textable protocol
- - (DText *) toText
- Return a text string with the double
- Returns:
- a (new) text string with the number
- Datable protocol
- - (DData *) toData
- Return a data string with the double
- Returns:
- a (new) data string
- Parsable protocol
- - (int) fromString :(char **) cstr
- Parse a string to set the double
- Parameters:
- cstr - the string to be parsed (moved to first non-parsable char)
- Returns:
- the result (0, ERANGE, ENODATA)
generated 06-Sep-2008 by ObjcDoc 3.0.0