[floats][infinity][C99]

Daniel Kochmański daniel at turtleware.eu
Fri Sep 4 08:50:00 UTC 2015


Hello,

I'm little in doubt. Problem is related to ieee-floating-point
extensions, which provide infinities and nan. Everything works fine
until we generate C code, which simply breaks, because it isn't taken
into account.

There are two possible solutions:

- for these cases use constant expressions, which trigger an error on
  some compilers, that is (0.0 / 0.0) for nan, (1.0 / 0.0) for infinity

- use defined by C99 macros: INFINITY and NAN, which will work on any
  compiler supporting C99.

Using the latter is clean and elegant, but raises requirements of ECL
for C backend.

Regarding compilers, C99 is considered complete since GCC 4.5 (and
partly complete in previous versions), while MSVC implemented them with
VS2013 (however ECL runs with bytecmp, so if no additional package using
infinities is added during buildtime, there should be no problem with
using previous versions).

I'm writing to ML to ask your opionions - should we use these macros?

Best regards,
Daniel

-- 
Daniel Kochmański | Poznań, Poland
;; aka jackdaniel

"Be the change that you wish to see in the world." - Mahatma Gandhi



More information about the ecl-devel mailing list