From e3887d7ead27ac092045b0e54e639b288513b163 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Wed, 3 May 2023 00:12:36 -0400 Subject: [PATCH] Test to demonstrate availability of floating point constants, document the possibility. --- doc/cc65.sgml | 3 +++ test/val/float-const-convert.c | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 test/val/float-const-convert.c diff --git a/doc/cc65.sgml b/doc/cc65.sgml index 683249bda..af85a057f 100644 --- a/doc/cc65.sgml +++ b/doc/cc65.sgml @@ -805,6 +805,9 @@ and the one defined by the ISO standard: The datatypes "float" and "double" are not available. + Floating point constants may be used, though they will have to be + converted and stored into integer values. + Floating point arithmetic expressions are not supported.

C Functions may not return structs (or unions), and structs may not be passed as parameters by value. However, struct assignment *is* diff --git a/test/val/float-const-convert.c b/test/val/float-const-convert.c new file mode 100644 index 000000000..729595e0f --- /dev/null +++ b/test/val/float-const-convert.c @@ -0,0 +1,14 @@ +/* Demonstrates that floating point constants are allowed in a limited way. + Value will be converted to an int, with a warning if precision is lost. */ + +int a = 3.0; +int b = 23.1; +int c = -5.0; + +int main(void) +{ + if (a != 3) return 1; + if (b != 23) return 2; + if (c != -5) return 3; + return 0; +}