Results 1 to 2 of 2

Thread: disable scientific notation conversion

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    15

    disable scientific notation conversion

    Hi Guys,

    Is there a way to disable converting > 15 digits number to Scientific Notation.

    For example: i Want to retain this Number: 100000000000000000123 from not converting into 1E+20. I can't use string because i always make computation with this large number..



    Thanks

  2. #2
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: disable scientific notation conversion

    Use subtype Decimal of type Variant.
    Try this:
    Code:
       Dim d As Variant
       Dim x As Variant
       Dim y As Variant
       Dim z As Variant
       
       d = CDec(1)
       d = d * 123456789012345#
       
       x = d * d '-- * return a Decimal value
       Debug.Print TypeName(x), x '-- Decimal        15241578753238669120562399025
       
       y = d ^ 2 '-- ^ return a Double value with maximum of 15 significant digits
       Debug.Print TypeName(y), y '-- Double         1.52415787532387E+28
       
       z = CDec(d ^ 2) '-- Convert a Double value to Decimal 
                       '-- but still has maximum of 15 significant digits
       Debug.Print TypeName(z), z '-- Decimal        15241578753238700000000000000
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

Posting Permissions

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



Click Here to Expand Forum to Full Width