Consulting

Results 1 to 12 of 12

Thread: Decimal Type ?

  1. #1
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location

    Decimal Type ?

    in another post about converting to binary, we have encountered a problem trying to represent a number greater than what Long can handle. Single and Double handle "larger" numbers, but not more digits. The Mod function overflows if the "A" in A Mod B is larger than the 2+ billion that a Long can handle (does not matter what type A is).

    What is the story with "Decimal" type. I have encountered many references, but there is always a caveat about "not being supported".
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  2. #2
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    From the help file:

    Decimal Data Type

    Decimal Variables are stored as 96-bit (12-byte) signed integers scaled by a variable power of 10. The power of 10 scaling factor specifies the number of digits to the right of the decimal point, and ranges from 0 to 28. With a scale of 0 (no decimal places), the largest possible value is +/-79,228,162,514,264,337,593,543,950,335. With a 28 decimal places, the largest value is +/-7.9228162514264337593543950335 and the smallest, non-zero value is +/-0.0000000000000000000000000001.

    Note At this time the Decimal data type can only be used within a Variant, that is, you cannot declare a variable to be of type Decimal. You can, however, create a Variant whose subtype is Decimal using the CDec function

    By the way, if you don't mind me asking, where in NY are you?

  3. #3
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by mvidas
    From the help file:

    Decimal Data Type

    Decimal Variables are stored as 96-bit (12-byte) signed integers scaled by a variable power of 10. The power of 10 scaling factor specifies the number of digits to the right of the decimal point, and ranges from 0 to 28. With a scale of 0 (no decimal places), the largest possible value is +/-79,228,162,514,264,337,593,543,950,335. With a 28 decimal places, the largest value is +/-7.9228162514264337593543950335 and the smallest, non-zero value is +/-0.0000000000000000000000000001.

    Note At this time the Decimal data type can only be used within a Variant, that is, you cannot declare a variable to be of type Decimal. You can, however, create a Variant whose subtype is Decimal using the CDec function

    By the way, if you don't mind me asking, where in NY are you?
    \

    from what Help file did you extract the above. I searched for decimal type through several VBA help utilities and found nothing. Searching on Cdec (now that I know about it), lead to similar results to yours.

    near Rochester.
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    It appears in Excel 2003 VBA help.

  5. #5
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    So, mvidas and mdmackillop, u mean that i need to redo the mod function when convert dec to bin when input too huge? Can give some ideas to solve it? Thanks.

    Related Thread:
    Convert Decimal To Binary http://www.vbaexpress.com/forum/showthread.php?t=3599

    Thanks a lot.

  6. #6
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    It is in my excel 2k help file as well, that is where I posted it from.

    We now have a third Rochester area person? How cool! JOrzech and I are both from Rochester (actually we both live and work downtown), how far outside Roch are you? I'm from Spencerport originally, I've been living downtown about 4 years.

    Sheeeng,
    I'll take a better look at the decimal to binary thread tomorrow when I have a few minutes.

  7. #7
    Moderator VBAX Mentor sheeeng's Avatar
    Joined
    May 2005
    Location
    Kuala Lumpur
    Posts
    392
    Location
    Thanks, mvidas.

  8. #8
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Also for the decimal data type (though it is the exact same as above), the information is at http://msdn.microsoft.com/archive/de.../D6/S5B20F.asp

  9. #9
    VBAX Expert
    Joined
    Feb 2005
    Posts
    929
    Location
    Quote Originally Posted by mvidas
    It is in my excel 2k help file as well, that is where I posted it from.
    it is amazing how simple it is to find things when someone else gives you a hint. For reasons not clear each time I played around with a VBA search, I did not find the Decimal Type (for the 300+ secondary selections). Of course, once I did find it and clicked on it, VBA Help exploded (as it often does)

    Quote Originally Posted by mvidas
    We now have a third Rochester area person? How cool! JOrzech and I are both from Rochester (actually we both live and work downtown), how far outside Roch are you? I'm from Spencerport originally, I've been living downtown about 4 years.
    I haved lived in Fairport for over (egads!) 30 years
    "It's not just the due date that's important, it's also the do date" [MWE]

    When your problem has been resolved, mark the thread SOLVED by clicking on the Thread Tools dropdown menu at the top of the thread.

  10. #10
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Well, unfortunately/fortunately (depending on how you look), I am still a young'n, and haven't really found a place (either around rochester or anywhere else) that I care to really settle down in yet (much less live for 30 years). I've spent a good amount of time in Fairport, so I can definately see the appeal!
    I'm very excited to find out that there's another 'local' around here, and you're an Excel fan to boot!

  11. #11
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by MWE
    it is amazing how simple it is to find things when someone else gives you a hint. For reasons not clear each time I played around with a VBA search, I did not find the Decimal Type (for the 300+ secondary selections). Of course, once I did find it and clicked on it, VBA Help exploded (as it often does)
    I find searcfhing in Help absolutely useless, I never seem to find what I want. But ... if you type a word in the immediate window, select it, and the F1, you usually can find something. This works well for me (even though I don't live in Rochester , but I do have a friend there, Tony Bruno, long shot I know, but you don't know him perchance?).

  12. #12
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Quote Originally Posted by xld
    I do have a friend there, Tony Bruno, long shot I know, but you don't know him perchance?
    I don't know a Tony Bruno, sorry. The name sounds familiar, but thats the extent of it. This isn't a huge city so there is always a possibility that I've seen him

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •