• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

larger numbers

what field type can i use to store a very very large number.

i want to multple this number by 3

3990000070756820

so the number ends up to be:

11970000212270460

but i get a number like this:

4.19700002122705E+16

ideas...
0
tomhoran
Asked:
tomhoran
  • 6
  • 5
  • 2
1 Solution
 
JacamarCommented:
declare that variable as a double.  It can be very large.
I think a textbox would work as good as anything to enter that number in.
0
 
tomhoranAuthor Commented:
but i end up with a number like this

1.25910000636811E+17
0
 
JacamarCommented:
doubles can go up to plus or minus

1.8 E+308

What is the problem?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
JacamarCommented:
if you don't want the number to be displayed like that, do this.

Picture1.Print Round(Variablename, 3)

That will round to 3 decimal places
0
 
tomhoranAuthor Commented:
what i'm really looking to do is:

WkAcctNo = WkAcctNo * 3
WkAcctNo = WkAcctNo / 2

then store the results in a varchar data field as whole number string like

123456789123123

not

1.123123+18

Thanks
0
 
JacamarCommented:
oh, i gotcha,  give me a couple min
0
 
JacamarCommented:
Unfourtunately the double variable type only goes up to 15 or 16 significant digits.  I am not aware of a way that will solve your problem.  
0
 
PNJCommented:
Try format$(WkAcctNo,"#")

Eg:
?  12.34e16
 1.234E+17
?  format$(12.34e16,"#")
123400000000000000
0
 
tomhoranAuthor Commented:
the format does it but your right it's truncating the number after the multiplication. isn;t there any other number types? i tried varant, but that didn't work.
0
 
PNJCommented:
Try "Help Decimal" It says:

Decimal variables are stored as 96-bit (12-byte) unsigned 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.

Is that big enough?

Sub Test()
   Dim ATest As Variant
   ATest = CDec("3990000070756820")
   ATest = ATest * 3
   Debug.Print Format$(ATest, "#")
   Exit Sub
End sub

test
11970000212270460

Yup, that does it.
0
 
tomhoranAuthor Commented:
were getting close. it's rounding.

xx = 13990000070756820 * 3

xx should = 41970000212270460

but VB returns 41970000212270500  

it's rounding the 460 to 500? Why?
0
 
tomhoranAuthor Commented:
never mind i think i got it, hold on
0
 
tomhoranAuthor Commented:
Thanks for everyones help .. here is the working code:


Dim WkAcctNo As Variant

WkAcctNo = CDec(WkAcctNo)
WkAcctNo = WkAcctNo * 3
WkAcctNo = WkAcctNo / 2
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 6
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now