myDecimal = new decimal(new int[] { 0, 0, 0, 0});

Posted on 2006-03-22
Last Modified: 2010-04-16

Anyone know what this code does?


myDecimal = new decimal(new int[] { 0, 0, 0, 0});
Question by:paulwhelan
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    in intializes an array of 4 items with each item having the value of 0
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    actually, it creates a decimal with the value of the 4 bytes initalized to 0

    Author Comment

    Would this not suffice?

    myDecimal = new int[] {0,0,0,0};

    Author Comment

    "actually, it creates a decimal with the value of the 4 bytes initalized to 0"

    What does that mean?
    LVL 85

    Accepted Solution

    See the documentation here:

    The binary representation of a Decimal number consists of a 1-bit sign, a 96-bit integer number, and a scaling factor used to divide the integer number and specify what portion of it is a decimal fraction. The scaling factor is implicitly the number 10, raised to an exponent ranging from 0 to 28.

    bits is a four-element long array of 32-bit signed integers.

    bits [0], bits [1], and bits [2] contain the low, middle, and high 32 bits of the 96-bit integer number.

    bits [3] contains the scale factor and sign, and consists of following parts:

    Bits 0 to 15, the lower word, are unused and must be zero.

    Bits 16 to 23 must contain an exponent between 0 and 28, that indicates the power of 10 to divide the integer number.

    Bits 24 to 30 are unused and must be zero.

    Bit 31 contains the sign; 0 meaning positive, and 1 meaning negative.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now