typespec icon indicating copy to clipboard operation
typespec copied to clipboard

Adding decimal as an intrinsic type

Open marron-at-work opened this issue 3 years ago • 6 comments

It would be useful to have a decimal intrinsic type available. While it is possible to define a custom one (using scalar extends) this seems like a frequent (and high value) enough numeric type to include in the built-in set.

For the purposes of modeling I don't think we need to worry about rounding modes or similar. However, I think it is worth discussing if the design should be a fixed size -- say like the dotnet decimal or an unbounded size that the emitters can limit as desired.

marron-at-work avatar Mar 22 '23 05:03 marron-at-work

A concrete proposal might be adding:

scalar decimal extends numeric; // unbounded, big decimal
scalar decimal128 extends decimal;
~~scalar decimal64 extends decimal128;~~
~~scalar decimal32 extends decimal64;~~

I tend to agree that these should be built in.

bterlson avatar Mar 22 '23 14:03 bterlson

It's great that you're doing this. It will be useful for financial models.

stephengoldbaum avatar Mar 24 '23 17:03 stephengoldbaum

Add decimal and decimal128. No to decimal64 and 32 for now, but chime in if you have feedback on this point!

bterlson avatar Apr 27 '23 16:04 bterlson

Excellent!

stephengoldbaum avatar Apr 30 '23 23:04 stephengoldbaum

  • add linting rules to prevent usage in azure.core based specs

markcowl avatar May 03 '23 18:05 markcowl

Closing as completed

markcowl avatar Jun 02 '23 20:06 markcowl