in reply to POSIX and -Dusequadmath

I've looked at several POSIX documents (limits.h, math.h, float.h). It seems that POSIX knows only float, double, and long double. According to Wikipedia, long double may be a 128 bit float - but unfortunately, that depends on the implementation. On x86, it is commonly the 80 bit float format of the 80x87. HP-UX and Solaris/SPARC actually use the name long double for 128 bit floats. And compilers may choose to treat long double as an alias for double, like MS VC++ does.

It looks like quadmath.h is no POSIX standard header. So strictly speaking, the FLT128_XXX definitons don't belong into the POSIX module.

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: POSIX and -Dusequadmath
by syphilis (Archbishop) on Sep 09, 2017 at 12:02 UTC
    the FLT128_XXX definitons don't belong into the POSIX module

    Yeah ... I had a vague notion that those definitions might be outside of POSIX's "terms of reference".

    That being so, what is the best way to assign the FLT128_MAX value to a scalar on a -Dusequadmath perl (and without calling on a non-CORE module) ?
    I really can't think of any better way than doing $nv_max = 1.18973149535723176508575932662800702e4932;
    But that string of numbers is not quite as easy to remember as "POSIX::FLT128_MAX".
    A little easier to remember is $nv_max = 0x1.ffffffffffffffffffffffffffffp+16383 except that it provides the wrong result on perl-5.22.0 (the first stable release of perl to support -Dusequadmath):
    $ perl -le '$x = 0x1.ffffffffffffffffffffffffffffp+16383; print $x;' Inf
    Just lately I seem to often want to assign NV_MAX to a perl scalar (for various exercises regarding some testing of code).
    For nvtype='double' I can use POSIX::DBL_MAX and for nvtype='long double' I can use POSIX::LDBL_MAX. It would therefore be nice to be able to use POSIX::FLT128_MAX when nvtype='__float128'.
    But if that can't be then it's really not such a big deal to use other means, though it is a bit of a nuisance having to continually look up the value.

    Cheers,
    Rob
      You can consider building a private module to define "seldom used" constants such as this. I would include "user" constants such as your local longitude and latitude, and characteristics of your hardware.
      Bill
        You can consider building a private module to define "seldom used" constants such as this

        Well, I have Math::Float128 installed - so I can access the various __float128 constants using it. However, the tests need to work on perls where Math::Float128 is not installed, so I have to enter in the actual numeric value instead of (eg) Math::Float128::FLT128_MAX.

        It's not often that I need to find hardware or geographical information - but whenever I do, it inevitably takes me bloody ages.
        I like the idea of having such a "user" module !!

        The main point of this thread was to get thoughts regarding whether the constant should be in the POSIX module.
        And later it occurred to me that if it were now to be added to the POSIX module, it wouldn't really help (because it would still be missing on perls 5.22 to 5.26, anyway).

        Cheers,
        Rob

      Nothing in use Config to help you?

      As an aside, if you fancy a laugh, enter that constant into Wolfram Alpha and see what happens :)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
      In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit
        Nothing in use Config to help you?

        Nothing there that I could see.

        enter that constant into Wolfram Alpha and see what happens

        You've given me a link to an error page. When I go to https://www.wolframalpha.com/ and perform a calculation involving that constant it seems ok.
        I'm thinking that either you struck some sort of random server error, or I'm being dense. (I reckon it's an even money bet either way ;-)

        Cheers,
        Rob