Bioplib
Protein Structure C Library
 All Data Structures Files Functions Variables Typedefs Macros Pages
Functions
ftostr.c File Reference

Convert a REAL to a string. More...

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "MathType.h"
#include "SysDefs.h"
#include "macros.h"

Go to the source code of this file.

Functions

char * blFtostr (char *str, int maxlen, REAL x, int precision)
 

Detailed Description

Convert a REAL to a string.

Version
V1.4
Date
07.07.14

This program is not in the public domain, but it may be copied according to the conditions laid out in the accompanying file COPYING.DOC

The code may not be sold commercially or included as part of a commercial product except as described in the file COPYING.DOC.

Institute of Structural & Molecular Biology, University College London, Gower Street, London. WC1E 6BT.
andre.nosp@m.w@bi.nosp@m.oinf..nosp@m.org..nosp@m.uk andre.nosp@m.w.ma.nosp@m.rtin@.nosp@m.ucl..nosp@m.ac.uk

This code is NOT IN THE PUBLIC DOMAIN, but it may be copied according to the conditions laid out in the accompanying file COPYING.DOC.

The code may be modified as required, but any modifications must be documented so that the person responsible can be identified.

The code may not be sold commercially or included as part of a commercial product except as described in the file COPYING.DOC.

Description:

Convert a REAL to a string

Usage:

Revision History:

Definition in file ftostr.c.

Function Documentation

char* blFtostr ( char *  str,
int  maxlen,
REAL  x,
int  precision 
)
Parameters
[out]*strString version of number
[in]maxlenMax length for f-form. Switches to e-form if exceeded
[in]xNumber to convert
[in]precisionNumber of decimal places If negative, use e-form rather than f-form
Returns
Same as str

Convert a REAL to a string using precision decimal places. If precision is negative, use e-form, otherwise use f-form. This is used to generate precisely formatted string versions of numbers for applications where the appearance of a numeric value is important.

  • 01.07.92 Original
  • 07.07.92 Changed to stop value of -0.0
  • 24.07.92 Added maxlen parameter. If the f-form will exceed this number of characters we switch to e-form autmatically
  • 28.07.92 If precision -ve, is never < maxlen-5
  • 27.07.93 Changed to double precision I/O
  • 09.10.97 If precision is 0 prints as an integer since C libraries handle "%.0f" inconsistently
  • 14.11.97 Oops, had forgotten to fix this in the check for e-form
  • 03.06.05 Tidied up some loops to stop warnings under GCC 3.2.2
  • 07.07.14 Use bl prefix for functions By: CTP

Definition at line 133 of file ftostr.c.