Solved

SQL: Factorial:: large numbers

Posted on 2013-06-17
5
493 Views
Last Modified: 2013-06-18
Hello team,
A non-recursive method in below will give me what I need, however, I would like to have a larger number than 38! and I know that either numeric or decimal can handle +- 38.  
Is there a way to use one of the 2 mentioned data types and use all the 72, not using the negative range?
(see attached)

Any assistance will be appreciated.
thx
factorial.png
0
Comment
Question by:John Esraelo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Accepted Solution

by:
DcpKing earned 100 total points
ID: 39254861
float
      

- 1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308

(ref: http://msdn.microsoft.com/en-us/library/ms173773.aspx)

hth

Mike
0
 
LVL 16

Assisted Solution

by:Surendra Nath
Surendra Nath earned 400 total points
ID: 39254866
by using float one will loose the precission, i.e. in this case he will loose the last few digits....

I believe there is no data in sql server that will natively support this huge data, if there is one .NET you can use the SQL CLR functionality to get it loaded into SQL.
0
 

Author Closing Comment

by:John Esraelo
ID: 39254898
I am aware of all the data types but appreciate your responses.
I might start looking into some calculations in other bases, such as hex or something.. then convert the result to a character string.
0
 
LVL 16

Expert Comment

by:DcpKing
ID: 39255964
I think that if you are working with integers you might try converting all your numbers into right-justified, left-zero-filled varchars and then writing CLR functions in C# for adding, dividing, subtracting and multiplying. You might also search for articles on ASCII arithmetic and BCD.

Good luck!


Mike
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 39256466
This closed, but the number space of factorials is so small that you could just pre-compute them (or look them up) and store them in a table as strings.
Here they all are from 1 to 256
http://membres.multimania.fr/rsirdey/facttabl.htm
Just put those in the database and look them up. Don't bother doing all the math yourself.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

724 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