Function Entry: ATOF
← Prev | ↑ Chapter | Next → | Index | Symbols
Function Entry: ATOF
Name
atof
Class
Conversion Function
Syntax
(atof string)
Arguments and Values
string: a string representing any number.
Description
Converts string into a double-precision real. A trailing non-numeric tail terminates parsing; the numeric prefix is returned.
Return Values
A double-precision real; 0.0 if the string is not a valid number.
Side Effects
None.
Examples
(atof "12")returns12.0.(atof "12.34")returns12.34.(atof "xyz")returns0.0.
Implementation-defined Behaviour
The Phase-5 vendor citations below define the documented surface. Several lexical edges are not nailed down by either vendor's prose and remain implementation-defined unless and until product tests exist:
.5,1.— leading/trailing decimal-point variants.- Exponent notation (
1e3,1E+03). - Leading whitespace handling.
- Locale sensitivity, in particular decimal-comma vs decimal-point.
- Acceptance of hexadecimal floating syntax (
0x1p4). - Trailing-junk strictness.
For clautolisp the chosen lex model is: skip leading whitespace, accept optional sign, accept the longest prefix matching (digits '.' digits?) | (digits? '.' digits) | digits followed by an optional exponent (('e'|'E') [+-]? digits), no locale sensitivity (decimal-point only), no hexadecimal floating syntax. At least one digit must appear on some side of the dot — vendor AutoLISP reads 42. as 42.0, 5. as 5.0, and .5 as 0.5, distinct from CL's reading of 42. as the integer 42. The probe suite in probe-atof.lsp records the AutoCAD / BricsCAD product behaviour when run via scripts/run-probes.sh.
Tested Behaviour (BricsCAD V26 / macOS, 2026-04-26)
Probe results from results/bricscad/macos/20260426T122808Z/results.sexp:
| Probe | Returned | Note |
|---|---|---|
(atof "3.5") |
3.5 |
baseline |
(atof ".5") |
0.5 |
leading-dot accepted |
(atof "1.") |
1.0 |
trailing-dot accepted |
(atof "1e3") |
1000.0 |
exponent accepted |
(atof "017") |
17.0 |
leading zero treated as decimal |
(atof "0x1p4") |
16.0 |
hexadecimal floating syntax accepted — BricsCAD V26 delegates to a strtod(3)-style implementation with C99 hex-float support |
(atof "3,5") |
3.0 |
decimal-comma rejected; parsing stops at the comma (no locale sensitivity in BricsCAD V26 / macOS) |
(atof " 3.5") |
3.5 |
leading whitespace accepted |
The 0x1p4 → 16.0 result is the most significant finding: BricsCAD V26 does accept hex-float input. The conservative clautolisp lex model rejects it; conformant code that targets BricsCAD V26 may expand the lex model to include hex-floats. Locale sensitivity is not present on the macOS build; portable AutoLISP code should not rely on locale.
Availability
- AutoCAD 2026: documented (Autodesk reference page).
- BricsCAD V26: documented + product-tested on macOS (probe suite, 2026-04-26).
- Status: documented in both vendors; lex-edge behaviour now tested against BricsCAD V26 / macOS. AutoCAD product test deferred until a local install becomes available.
See Also
- probe-atof.lsp — executable Phase-5 probe suite.
rtos— real-to-string companion.
Source Notes
- [atof (AutoLISP 2026)](https://help.autodesk.com/cloudhelp/2026/ENU/AutoCAD-AutoLISP-Reference/files/GUID-8618A388-E4CF-40E1-813B-057367DD1840.htm)
- [atof (BricsCAD V26 DevRef)](https://developer.bricsys.com/bricscad/help/en_US/V26/DevRef/source/atof.htm)
- Status: documented (Phase 5 closure via vendor citation; product-test coverage deferred until a CAD product is available locally).