Results 1 to 3 of 3

Thread: Floating-point Constants

  1. #1
    Diogo Teixeira

    Floating-point Constants

    I'm part of a team working on free and open source implementations of the OpenKODE specification for many platforms.

    While working on the Utility functions we noticed the following macros, defined in kd.h, may be a source of problems with some C and C++ compilers:

    #define KD_INFINITY (1.0F/0.0F)
    #define KD_NAN (0.0F/0.0F)
    #define KD_HUGE_VALF ( 1.0F/0.0F)

    Although they define perfectly valid floating-point arithmetic according to the IEC 559 / IEEE 754 standard, some standards specify that an explicit division-by-zero is the product of an ill-formed program. This usually
    in either undefined behaviour or a compile time error. The latter occurs in the MS C Compiler but we think it's safe to assume that this may happen in other compilers.
    Our current solution involves using platform dependent constants selected at compile time. However, we intend to fully comply with the spec.

    What is the best way to deal with this issue?

  2. #2
    Junior Member
    Join Date
    Nov 2007

    KD_NAN is not in the latest draft of the specification; it has been
    replaced by a kdIsNan macro to tell whether a variable is NaN.

    We have noticed the same problem with 1.0F/0.0F. To allow each
    implementation to work round this in its own way, the specification now
    states that KD_INFINITY is IEEE infinity, but does not mandate how your
    kdplatform.h should achieve that.
    Tim Renouf
    Antix Labs Limited
    OpenKODE Specification Editor

  3. #3
    Diogo Teixeira
    Hi Tim, thanks for responding.

    We ended up modifying kd.h, following the same path as Acrodea.

    Is there a time frame for the release of a new draft?

    Our implementation for Win, WinCE, Mac and Linux is close to a release. We are wondering how well is OpenKODE being supported by ISV/HSVs?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts