GNOME Bugzilla – Bug 766844
I miss extended gcc floating types.
Last modified: 2018-05-22 15:34:57 UTC
Some time ago Vala has pulled my attention as a way to solve some kind of math problems. But some time later I realized that this cozy and beautiful staff does not have extended floating datatypes such as long double or __float128_t. So I will be very happy if I am able to write everything in Vala instead of intermixing C code with Vala. Vitaly
Created attachment 328457 [details] Initial attempt at a basic long double binding
Created attachment 328458 [details] Basic Vala program to demonstrate the binding Place long_double.vapi in your current working directory and compile with: valac --pkg long_double --vapidir . long_double.vala This is a basic binding to get things started. Please report back that things work as expected, with any test cases you may generate. I'm not planning to do any more work on this, but if others want to carry on with it this is a start.
At first, I found your solution really useful for me. Thanks. But there is one small issue: we should mark long double constants with L in corresponding C code. Currently gcc reads constants as double, drop extra digits, and only then covert them to long double. With best regards, Vitaly
Created attachment 328466 [details] Second attempt at VAPI - added strtold() binding for longdouble.parse() Vala will allow the constant type to be given, e.g. longdouble a = 1.23f; If you change the test program to the above and compile with: valac --pkg long_double --vapidir . long_double.vala --ccode The --ccode switch will only generate the C code and you should see it includes the 'f'. The Vala scanner doesn't recognise the 'L' in a real literal. So someone would have to patch the scanner to accept that. This updated binding allows strtold() to be used to create the long, e.g. longdouble a = longdouble.parse( "1234.12345678901234567890" ) Hopefully that is enough for some more testing.
Yes, now I can achieve with Vala code same results as with C code. With best regards, Vitaly
Thanks for the patch, Al. I wonder where we should add strtold (and strtof, which seems to be missing as well). It is not defined by POSIX, but rather ISO/IEC 9899:1999 (ISO C99). Since it adds a new basic type, should we rather add it to glib-2.0.vapi?
Once we have long doubles, we can also bind their utility functions, such as pow10l(3) and exp10l(3).
Created attachment 369035 [details] [review] WIP vala: Add support for "long double"
Created attachment 369043 [details] [review] WIP vala: Add support for "long double"
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/538.