All Manuals > LispWorks User Guide and Reference Manual > 38 The HCL Package

NextPrevUpTopContentsIndex

parse-float

Function
Summary

Parses a float from a string and returns it as float.

Package

hcl

Signature

parse-float string &key start end default-format => float

Arguments

string

A string

start, end

Bounding index designators for string

default-format

One of the atomic type specifiers short-float, single-float, double-float, or long-float.

Values

float

A float

Description

The function parse-float parses a float from the substring of string delimited by start and end and returns it as float.

If the substring represents an integer or the exponent marker is E or is omitted, then float will be of type default-format, which defaults to the value of *read-default-float-format*. Otherwise, its type will match the exponent marker as specified by 2.3.2.2 "Syntax of a Float" in the Common Lisp standard.

If the substring does not represent an integer or a float, then an error of type parse-error is signaled.

Examples
(parse-float "10") => 10.0f0 (parse-float "10" :default-format 'double-float) => 10.0d0 (parse-float "10d0") => 10.0d0 (parse-float "10.5") => 10.5f0 (parse-float "10.5d0") => 10.5d0

LispWorks User Guide and Reference Manual - 13 Feb 2015

NextPrevUpTopContentsIndex