I want to use dataype which can hold more than 19 digits. So is there any datatype available which can hold larger than 19 digits?
-
3Out of curiosity, what kind of problem needs to deal with values in quintillion range? Scientific computing comes into mind. – vonPryz Oct 15 '13 at 13:16
-
@vonPryz The calculation of modular multiplicative inverses for the generation of asymmetric keys is one thing that comes to my mind. It can be used to create a reversible 'randomization' of bigint numbers, for example. – Arthur Castro Oct 4 '19 at 13:40
-
@vonPryz Late to the game, but barcode numbers, voucher IDs and other long numbers? Or is it better practice to store that as nvarchars? – SvendK Nov 19 '20 at 10:14
-
@SvendK That really depends. Storing not-really-numbers such as GTIN codes as numbers can cause a lot of headaches. When the leading zeroes are mandatory, using a numeric type is not the smart solution. – vonPryz Nov 19 '20 at 10:41
Numeric/Decimal, Float/Real. There's a great answer here, some official documentation here and here, and I also posted a few opinions ages ago, but here is a quick demonstration:
-- overflow error:
DECLARE @x BIGINT = 9999999999999999999;
GO
-- works:
DECLARE @x DECIMAL(38,0) = 99999999999999999999999999999999999999;