Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the parse-float Reference Manual, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 14:36:57 2020 GMT+0.
• Introduction | What parse-float is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
This package exports the following function to parse floating-point values from a string in common lisp.
The information below is purposefully as close as possible to the text and format of parse-integer in the Common Lisp HyperSpec, but this package is not related to LispWorks in any way.
parse-float string &key start end radix junk-allowed decimal-character exponent-character type => float, pos
string---a string.
start, end---bounding index designators of string. The defaults for start and end are 0 and nil, respectively.
radix---a radix. The default is 10.
junk-allowed---a generalized boolean. The default is false.
decimal-character---a character separating the integer and decimal parts. The default is #\.
.
exponent-character---the exponentiation character (case insensitive). The default is #\e
.
type---a number type specifier. The default is *READ-DEFAULT-FLOAT-FORMAT*.
float---a float, depending on type, or false.
pos---a bounding index of string.
parse-float parses a float in the specified radix from the substring of string delimited by start and end into a number of the given type.
parse-float expects an optional sign (+ or -) followed by a a non-empty sequence of digits to be interpreted in the specified radix, optionally followed by decimal-character, a sequence of digits, exponent-character, a sign (+ or -) and a sequence of digits. Optional leading and trailing whitespace is ignored.
parse-float does not recognize the syntactic radix-specifier prefixes #O
, #B
, #X
, and #nR
, nor does it recognize the exponent if radix is not 10.
If junk-allowed is false, an error of type parse-error is signaled if substring does not consist entirely of the representation of a signed float, possibly surrounded on either side by whitespace characters.
The first value returned is either the float that was parsed, or else nil if no syntactically correct float was seen but junk-allowed was true.
The second value is either the index into the string of the delimiter that terminated the parse, or the upper bounding index of the substring if the parse terminated at the end of the substring (as is always the case if junk-allowed is false).
Load the package parse-float using Quicklisp:
(ql:quickload "parse-float")
Import the parse-float function:
(use-package :parse-float)
Use the imported parse-float function:
(parse-float "123") => 123.0, 3
(parse-float "123.1" :start 1 :radix 5 :type 'double-float) => 13.2d0, 5
(parse-float "123,0D2" :decimal-character #\, :exponent-character #\d :type 'single-float) => 12300.0, 7
(parse-float "no-integer" :junk-allowed t) => NIL, 0
(parse-float "1.2e-3" :type 'number) => 3/2500, 6
None.
None.
If junk-allowed is false, an error is signaled if substring does not consist entirely of the representation of a float, possibly surrounded on either side by whitespace characters.
parse-integer, [parse-number] (https://github.com/sharplispers/parse-number "parse-number on Github")
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The parse-float system |
Sumant Oemrawsingh
Public Domain
Parse floating point values in strings.
alexandria
parse-float.asd (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The parse-float.asd file | ||
• The parse-float/package.lisp file | ||
• The parse-float/parse-float.lisp file |
Next: The parse-float/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
parse-float.asd
parse-float (system)
Next: The parse-float/parse-float․lisp file, Previous: The parse-float․asd file, Up: Lisp files [Contents][Index]
parse-float (system)
package.lisp
Previous: The parse-float/package․lisp file, Up: Lisp files [Contents][Index]
package.lisp (file)
parse-float (system)
parse-float.lisp
parse-float (function)
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The parse-float package |
package.lisp (file)
parse-float (function)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported functions |
Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Similar to PARSE-INTEGER, but parses a floating point value and returns the value as the specified TYPE (by default *READ-DEFAULT-FLOAT-FORMAT*). The DECIMAL-CHARACTER (by default #.) specifies the separator between the integer and decimal parts, and the EXPONENT-CHARACTER (by default #e, case insensitive) specifies the character before the exponent. Note that the exponent is only parsed if RADIX is 10.
parse-float.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal constants | ||
• Internal functions | ||
• Internal types |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
List of whitespace characters
parse-float.lisp (file)
Next: Internal types, Previous: Internal constants, Up: Internal definitions [Contents][Index]
Parse an integer from a string, without skipping whitespaces. Returns three values: the integer, the position in the string that ended the parsing, and a boolean which is T if the parsing ended due to a whitespace or end of the string, and NIL otherwise. If allow-sign is NIL (T by default), also signs are not allowed in the string (i.e. cannot start with #+ or #-).
parse-float.lisp (file)
Predicate for testing if CHARACTER is a sign character (i.e. #+ or #-).
parse-float.lisp (file)
For the substring in STRING delimited by START and END, skip all the whitespace at the beginning and return the index of the first non-whitespace character, or END if no non-whitespace characters were found.
parse-float.lisp (file)
Predicate for testing if CHARACTER is a whitespace character.
parse-float.lisp (file)
Previous: Internal functions, Up: Internal definitions [Contents][Index]
A valid upper bound to a string.
parse-float.lisp (file)
A valid string index.
parse-float.lisp (file)
A valid Common Lisp radix.
parse-float.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L P |
---|
Jump to: | F L P |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | F P S W |
---|
Jump to: | F P S W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | +
C |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
+ | |||
+whitespace-characters+ : | Internal constants | ||
| |||
C | |||
Constant, +whitespace-characters+ : | Internal constants | ||
|
Jump to: | +
C |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | B P S T V |
---|
Jump to: | B P S T V |
---|