c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Add basic types support for IEEE 754 decimal32, decimal64 and decimal128

Open id3nom opened this issue 1 year ago • 9 comments

I propose to use the dec32, dec64 and dec128 type names.

It would ease financial application development. It would simplify database interop using the SQL DECIMAL type.

id3nom avatar Sep 16 '24 10:09 id3nom

We could do the integration like for the i128 type and when LLVM officialy release the IEEE 754 implementation replaced our implementation with LLVM's one.

Additional information for LLVM integration?

https://discourse.llvm.org/t/rfc-decimal-floating-point-support-iso-iec-ts-18661-2-and-c23/62152 https://github.com/tahonermann/llvm-project

id3nom avatar Sep 16 '24 10:09 id3nom

The question is: how bad would the experience be if this was implemented as user land types. I HAVE thought of it, but the fact that it's not often used in the languages that have it is sort of off-putting.

lerno avatar Sep 16 '24 12:09 lerno

In user land we would lost, implicit/explicit cast, and arithmetic operators support. And when the decimal types are gonna be available in LLVM, code using the user land type will need to be modified, Or we stick with the user land code and go forward with it?

id3nom avatar Sep 16 '24 12:09 id3nom

Would be nice to have a C3 interface like e.g.: IntegerType, FloatType, ..., that would allow a type to be defined with cast and arithmetic defined functions, and when the interface is implemented in a user type it would gives the same usage as the basic types.

id3nom avatar Sep 16 '24 12:09 id3nom

Would be nice to have a C3 interface like e.g.: IntegerType, FloatType, ...,

I've looked at this and it's a surprisingly big feature. If you have any detailed proposal I am definitely willing to look at it.

lerno avatar Sep 16 '24 21:09 lerno

Would be nice to have a C3 interface like e.g.: IntegerType, FloatType, ...,

I've looked at this and it's a surprisingly big feature. If you have any detailed proposal I am definitely willing to look at it.

I will work on a proposal this week. do you prefer that I post it in the Discussions >> Ideas section?

id3nom avatar Sep 18 '24 20:09 id3nom

That works fine.

lerno avatar Sep 18 '24 20:09 lerno

Ping

lerno avatar Mar 22 '25 22:03 lerno

Due to operator overloading, this is now more interesting as stdlib features.

lerno avatar May 15 '25 22:05 lerno