Solved

SQL: Factorial:: large numbers

Posted on 2013-06-17
5
489 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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how the fundamental information of how to create a table.

726 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