# cfloat Specification Sheet

Computer Algebra Kit (c) 1993,98 by Comp.Alg.Objects. All Rights Reserved.

# Float

Inherits from: CAObject

Maturity Index: Immature

## Class Description

It is planned to make this class evolve into an Objective C class for arbitrary precision floating-point arithmetic. Currently, Float is merely a Computer Algebra Kit compatible interface to plain C floating-point arithmetic. Instances are object wrappers around the float datatype; arithmetic is subject to the same limitations, round-off errors etc. as in C.

Support for floating-point arithmetic is minimal in the Computer Algebra Kit; it is possible to convert results that are obtained by exact arithmetic to a numerical approximation (see the method asNumerical of Integer, Matrix, Polynomial etc.) for further processing by numerical analysis software.

## Method types

### Creation

- new
- floatValue:
- str:

### Identity

- hash
- isEqual:
- floatValue
- floatValue:

### Comparing

- sign
- compare:

### Addition

- zero
- isZero
- isOpposite:
- negate
- double
- add:
- subtract:

### Multiplication

- one
- minusOne
- isOne
- isMinusOne
- square
- multiply:
- inverse
- divide:

### Printing

- printsLeadingSign
- printOn:

## Methods

### new

> +new

Creates an floating-point object equal to zero.

### floatValue:

> +floatValue:(float)floatValue

Creates an object with value equal to floatValue.

### str:

> +str:(STR)aString

Returns a new float object given a string aString, or returns nil if the method can't parse aString. This method acts like the ANSI function atof().

### floatValue

> - (float)floatValue

Returns the value of the object.

### floatValue:

> -floatValue:(float)f

Creates an object with value f.

### zero

> -zero

Returns a new reference to a shared float instance with value equal to zero.

### one

> -one

Returns a new reference to a shared float instance with value equal to one.

### minusOne

> -minusOne

Returns a new reference to the float minus one.

### printsLeadingSign

> - (BOOL)printsLeadingSign

Returns YES if the number is negative.

### printOn:

> -printOn:(IOD)aFile

Prints the floating-point number to aFile according to the '%g' format of the ANSI function printf().