Conversion of ascii string to floating-point, Floating-point performance, Conversion of ascii string to floating- point – Echelon Neuron C User Manual

Page 87

Advertising
background image

Neuron C Reference Guide

67

Conversion of ASCII String to Floating-
Point

Table 27 lists the conversion functions for an ASCII srtring to a floating-point

number.

Table 27. Conversions of ASCII Strings to Floating-Point Numbers

Short

Name Function

from
ascii

void fl_from_ascii(const char *arg1, float_type *arg2);
Converts an ASCII string to a floating-point number. The conversion

stops at the first invalid character in the input buffer—there is no error
notification. The acceptable format is the following:

[+/-][xx][.][xxxxx][E/e[+/-]nnn]

Examples:
0, 1, .1, 1.2, 1E3, 1E-3, -1E1
There should be no more than nine significant digits in the mantissa
portion of the number, or else the results are unpredictable. A

significant digit is a digit following any leading zeroes.
Embedded spaces within the number are also not allowed. This routine
uses repeated multiplication and division, and can be time-consuming,

depending on the input data.
Examples:

0.00123456789E4

// is acceptable

123.4567890

// is not acceptable

123 E4

// is not acceptable

The value 123.4567890 is not acceptable because it has 10 significant

digits, and the value 123 E4 is not acceptable because it has an
embedded space.

Floating-Point Performance

Table 28 lists times in milliseconds for the various functions in the floating-point

library. They were measured using a Series 3100 Neuron Chip with a 10 MHz

input clock. These values scale with faster or slower input clocks. The
measurements are maximums and averages over random data logarithmically

distributed in the range 0.001 to 1,000,000.

Table 28. Floating-Point Function Performance

Function

Maximum

Average

Add 0.56

0.36

Subtract 0.71

0.5

Advertising