Roslyn: [Proposal] bigint alias

Created on 14 Jun 2016  路  12Comments  路  Source: dotnet/roslyn

In F#, there is a language-wide alias for System.Numerics.BigInteger, which is bigint.

Does this make sense to include in C# at a language level?

0 - Backlog Area-Language Design Feature Request Language-C#

Most helpful comment

@gordanr It's almost possible already.

Assuming this simple type:

``` c#
static class ComplexConstants
{
public static readonly Complex i = Complex.ImaginaryOne;
}

And this `static` `using`:

``` c#
using static ComplexConstants;

You can write:

c# Complex z = 2.3 + 5.7*i; Complex z = 5.7*i;

All 12 comments

@asibahi: I totally agree. I also would like to propose some kind of bigint literal, to tell the compiler that the given number is of type bigint, e.g.:

bigint i = 315420000000000000000B;

@Unknown6656 The bigint literal in F# is I, capital. As in:

let aBigInt = 1000I

F# doesn't have implicit casting from int to bigint, as it happens

Very interesting proposal.

Shouldn't it be biginteger?:bike::house:

Could cause confusion for sql server bigint which equates to Int64.

@aluanhaddad : Well if it were biginteger, one could directly write BigInteger and simply import System::Numerics.......
I personally think, that bigint is better, as it is shorter :wink:

@BrettJacobitz : I (personally) do not think so....
I found it rather confusing the first time I worked with SQL, that bigint == Int64: I thought, that Int64 should be called long in SQL, and that SQL's bigint should be a datatype, which is 'bigger' than a 64Bit Integer number.

How about including complex

I would like to see both bigint and complex in c#. Very nice.
Complex numbers have two parts. What would the complex literal be like?

var z = (2.3, 5.7); // existing syntax, tuple or complex?

Could it be possible?
complex z = 2.3 + 5.7i;
complex z = 2.3 + i5.7;

What is the literal if we use only one part?
complex z = 2.3;
complex z = 5.7i;
complex z = i5.7;

@gordanr It's almost possible already.

Assuming this simple type:

``` c#
static class ComplexConstants
{
public static readonly Complex i = Complex.ImaginaryOne;
}

And this `static` `using`:

``` c#
using static ComplexConstants;

You can write:

c# Complex z = 2.3 + 5.7*i; Complex z = 5.7*i;

@svick, This is really cool piece of code. Look obvious, but I didn't know that trick. Thank you very much.

I am not sure if 2.3 + 5.7*i is compile time constant.

It is personal opinion, but I think that notation without '*' could be more appropriate.
complex z = 2.3 + 5.7i;

@gordanr that's a good point, it won't be a compile time constant but I don't think there's any way of avoiding that.
@svick very elegant. No new syntax, and the multiplication symbol is intuitive and correct.

Issue moved to dotnet/csharplang #805 via ZenHub

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MadsTorgersen picture MadsTorgersen  路  249Comments

gafter picture gafter  路  258Comments

Neil65 picture Neil65  路  112Comments

ilexp picture ilexp  路  167Comments

mgravell picture mgravell  路  119Comments