Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly is "bigint" in F#?

Tags:

f#

I understand that bigint is not a function but rather a type constructor. That's why this fails:

// Won't compile
let foo = 10 |> bigint

I understand that I can create a new function which accepts an integer and returns a bigint, and then the pipeline operator will work.

However, I don't understand why this works:

let bar = bigint 10

If bigint is a type constructor, why don't I need new? Where exactly is bigint defined as an alias to System.Numerics.BigInteger's constructor?

like image 722
royco Avatar asked Nov 07 '10 19:11

royco


People also ask

What is Bigint in C?

The BIGINT data type is a machine-independent method for representing numbers in the range of -2 63-1 to 2 63-1. ESQL/C provides routines that facilitate the conversion from the BIGINT data type to other data types in the C language. The BIGINT data type is internally represented with the ifx_int8_t structure.

Are integers value types in F#?

F# Data Types: int. An integer is a natural number that includes only digits and no other symbol. The F# languages supports various types of integers.


1 Answers

bigint is type abberviation for System.Numerics.BigInteger so when you type

let x = bigint 10

you actually create instance of BigInteger. In F# new is optional in constructors, basically it should be used when creating instances of types that implement IDisposable

like image 186
desco Avatar answered Sep 20 '22 16:09

desco