Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 modul of very huge integer

Author  Topic 

noamg
Posting Yak Master

215 Posts

Posted - 2007-01-30 : 01:45:15
I need to modul ( % operator) for very huge integers.
any idea how to do this ?
for example:
select 8798401245801245799987040 % 6987014548701011369

many thanks

Noam Graizer

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-30 : 01:48:57
Algebra 101
declare @a numeric(38, 0),
@b numeric(38, 0),
@q numeric(38, 0),
@d numeric(38, 0)

select @a = 8798401245801245799987040,
@b = 6987014548701011369

select @q = @a / @b,
@d = @a - @q * @b

select @q quote, @d remainder


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

noamg
Posting Yak Master

215 Posts

Posted - 2007-01-30 : 08:39:23
maybe the example include too low value. I mean to a very huge value.
integer with 30-60 digits !!!

Noam Graizer
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-30 : 08:53:46
Why don't you tell us the first time, and save us the hassle by going through this all over again.
See this topic http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=53268


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

noamg
Posting Yak Master

215 Posts

Posted - 2007-01-30 : 09:33:13
I know this link. Their is no modul (%) operator !

Noam Graizer
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-01-30 : 09:36:51
I know,
but did you look at the suggestion I provided earlier how to get the remainder (modula) without the function itself?

It is just a simple division and a subtraction with multiplication.

What is wrong with you? Is there not a division, subtraction and a multipliation in the link I provided?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -