After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 766844 - I miss extended gcc floating types.
I miss extended gcc floating types.
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Basic Types
unspecified
Other All
: Normal enhancement
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2016-05-24 17:07 UTC by Vitaly Chernooky
Modified: 2018-05-22 15:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Initial attempt at a basic long double binding (149 bytes, text/plain)
2016-05-24 19:29 UTC, Al Thomas
  Details
Basic Vala program to demonstrate the binding (206 bytes, text/plain)
2016-05-24 19:34 UTC, Al Thomas
  Details
Second attempt at VAPI - added strtold() binding for longdouble.parse() (257 bytes, text/plain)
2016-05-24 21:40 UTC, Al Thomas
  Details
WIP vala: Add support for "long double" (6.69 KB, patch)
2018-02-27 15:33 UTC, Rico Tzschichholz
none Details | Review
WIP vala: Add support for "long double" (17.12 KB, patch)
2018-02-27 16:32 UTC, Rico Tzschichholz
none Details | Review

Description Vitaly Chernooky 2016-05-24 17:07:45 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
Comment 1 Al Thomas 2016-05-24 19:29:45 UTC
Created attachment 328457 [details]
Initial attempt at a basic long double binding
Comment 2 Al Thomas 2016-05-24 19:34:09 UTC
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.
Comment 3 Vitaly Chernooky 2016-05-24 20:51:23 UTC
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
Comment 4 Al Thomas 2016-05-24 21:40:04 UTC
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.
Comment 5 Vitaly Chernooky 2016-05-24 22:25:48 UTC
Yes, now I can achieve with Vala code same results as with C code.

With best regards,

Vitaly
Comment 6 Michael 'Mickey' Lauer 2018-02-26 08:46:26 UTC
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?
Comment 7 Michael 'Mickey' Lauer 2018-02-26 16:08:32 UTC
Once we have long doubles, we can also bind their utility functions, such as pow10l(3) and exp10l(3).
Comment 8 Rico Tzschichholz 2018-02-27 15:33:23 UTC
Created attachment 369035 [details] [review]
WIP vala: Add support for "long double"
Comment 9 Rico Tzschichholz 2018-02-27 16:32:03 UTC
Created attachment 369043 [details] [review]
WIP vala: Add support for "long double"
Comment 10 GNOME Infrastructure Team 2018-05-22 15:34:57 UTC
-- 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.