[Solved] Understanding the result of the decimal constructor with 5 arguments [closed]


This is using the decimal constructor that allows you to specify different parts of the decimal value. From the linked documentation:

lo – The low 32 bits of a 96-bit integer.

mid – The middle 32 bits of a 96-bit integer.

hi – The high 32 bits of a 96-bit integer.

isNegative – true to indicate a negative number; false to indicate a positive number.

scale – A power of 10 ranging from 0 to 28.

Taking some simple examples, you can see how the different values affect the creation of the decimal value:

Console.WriteLine(new decimal(0, 0, 0, false, 0)); //0
Console.WriteLine(new decimal(1, 0, 0, false, 0)); //1
Console.WriteLine(new decimal(0, 1, 0, false, 0)); //4294967296
Console.WriteLine(new decimal(0, 0, 1, false, 0)); //18446744073709551616
Console.WriteLine(new decimal(1, 0, 0, false, 1)); //0.1
Console.WriteLine(new decimal(1, 0, 0, true, 1)); //-0.1

1

solved Understanding the result of the decimal constructor with 5 arguments [closed]