GNOME Bugzilla – Bug 722067
Add ABS() function for short type
Last modified: 2014-01-16 22:16:25 UTC
Created attachment 266086 [details] [review] Patch to add ABS function to short type The summary really says it all. This did involve a small amount of C code though.
See the following mailing list message for inspiration: https://mail.gnome.org/archives/vala-list/2013-December/msg00024.html
Sorry but, is it really necessary to use fabs? I guess converting to int would be easier no?
Also, you should be able to directly use the int abs like this: [CCode (cname = "abs", cheader_filename = "stdlib.h")] public short abs ();
(In reply to comment #2) > Sorry but, is it really necessary to use fabs? I guess converting to int would > be easier no? Now that I look again, yes, that would probably be better. I'll update the patch.
Created attachment 266087 [details] [review] Add ABS function to short type Updated based on comments from Luca Bruno
What's the problem in doing straight: [CCode (cname = "abs", cheader_filename = "stdlib.h")] public short abs ();
Ah! Because I didn't fully understand what you meant in Comment 3.
Created attachment 266221 [details] [review] Add ABS function to short type
Created attachment 266222 [details] [review] Add ABS function to short type
commit 69ed59dc5b5b837eb0f6247e79c40817fd38051f Author: Steven Oliver <oliver.steven@gmail.com> Date: Thu Jan 16 22:41:23 2014 +0100 glib-2.0: Add abs() to short type Fixes bug 722067 Should not have been static. Anyway, I've fixed it for you. This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.
Awesome! Thanks for quick resolution!