You are looking at historical revision 17449 of this page. It may differ significantly from its current revision.

## Introduction

The `fpio` library contains a routines for converting floating-point numbers between IEEE binary representation and decimal string representation. It is based on the gdtoa library by David Gay.

There are two routines included with the library, `string->fp` and `fp->string`.

## Library procedures

`fp->string:: NUMBER [* NDIGITS] -> STRING`

Converts the given floating-point number to decimal string representation. If optional argument `NDIGITS` is positive, the conversion is done to the specified number of decimal places. If `NDIGITS` is zero (the default) or negative, the conversion is done to the shortest decimal string that rounds to the given floating point value.

`string->fp:: STRING [* ROUNDING] -> NUMBER`

Converts the given decimal string number to binary IEEE floating point representation. Optional argument `ROUNDING` is a symbol that can be one of:

`toward-zero`- indicates rounding-towards-zero mode (the default)
`nearest`- indicates rounding-towards-nearest mode
`toward+Inf`- indicates rounding-towards +Inf mode
`toward-Inf`- indicates rounding-towards -Inf mode

## Authors

Ivan Raikov

## Version

- 1.4
- Added import of foreign library [thanks to felix]
- 1.3
- Ported to Chicken 4
- 1.2
- Fixes to the file manifest
- 1.0
- Initial version

## License

Copyright 2008-2010 Ivan Raikov.

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that the copyright notice and this permission notice appear in supporting documentation.