Coder Social home page Coder Social logo

arteymix / numeric-glib Goto Github PK

View Code? Open in Web Editor NEW
9.0 1.0 2.0 94 KB

Numeric data types for GLib via GCC extensions

License: GNU Lesser General Public License v3.0

Vala 26.98% C 60.72% C++ 9.58% Meson 2.73%
vala gcc-extensions decimal 128-bit 80-bit

numeric-glib's Introduction

Numeric-GLib

Numeric data types for GLib via GCC extensions

Features

  • 128 bit integers with int128 and uint128
  • float80 and quad-precision float128
  • decimal with decimal32, decimal64 and decimal128
  • C99 complex, complex80 and complex128
  • vectorized operations on supported types
  • little and big endian variants with _le and _be suffix

All types are prefixed with numeric_, but can be used as-is by importing the Numeric namespace in Vala.

Usage

In Vala, one can simply add --pkg=numeric-glib-1.0 to include the type definitions and link against the shared library to initialize all the types and transformations.

vala --pkg=numeric-glib-1.0 main.vala

Or via Meson, the numeric_glib dependency can be included in any target.

project('Foo')

glib = dependency('glib-2.0')
gobject = dependency('gobject-2.0')
numeric_glib = dependency('numeric-glib-1.0', fallback: ['numeric-glib', 'numeric_glib_dep'])
numeric_glib_vala = dependency('numeric-glib-1.0', fallback: ['numeric-glib', 'numeric_glib_vala_dep'])

executable('foo', 'foo.c', dependencies: [glib, gobject, numeric_glib])
executable('foo', 'foo.vala', dependencies: [glib, gobject, numeric_glib_vala])

numeric-glib's People

Contributors

arteymix avatar rainwoodman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

numeric-glib's Issues

Usage with printf

I'm trying to debug some code but I can't figure out how to print the value of a decimal128 to the screen. Can it be used in a printf statement?

Endianess

I think we can address endianess of types in Numeric-GLib by defining type with explicit endianess (e.g. Numeric.float_be. The type would be boxed and conversion would bring it to a native endianess for further processing.

name

vala-gnumath vs numeric-glib.

Is decimal128 broken?

private static inline void test_foo () {
    Numeric.decimal128 a = 0.1;
    Numeric.decimal128 b = 0.1;
    Numeric.decimal128 c = 0.1;
    Numeric.decimal128 d = -0.3;

    Numeric.decimal128 expected = 0;

    assert_true (a + b + c + d == expected);
}

This test fails for me. It works if I replace decimal128 with decimal64 though. What's going on?

Cant build

../src/numeric-types.h:38:50: error: two or more data types in declaration specifiers
 typedef __float128                               _Float128;
                                                  ^~~~~~~~~

Can't use decimal128 for properties in a class inheriting from GLib.Object

It seems decimal128 can't be used for properties in classes inheriting from GLib.Object.

Failing Code

public class Foo : GLib.Object {
    public Numeric.decimal128 bar {
        get { return 0; }
    }
}

Error Output

numeric-glib-1.0.vapi:131.2-131.25: error: The type `Numeric.decimal128` doesn't declare a GValue set function
	public struct decimal128

Working Code

public class Foo {
    public Numeric.decimal128 bar {
        get { return 0; }
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.