The fastest way to find Quotient by separating two numbers

I need to do some logic based on the following implementation.

I have a large number of up to 36 digits, for example. 913695089923267549815145223638290430 (randomly generated by various applications). I need to divide it by any number shorter in length, for example, 70368844197664 (randomly generated by various applications) Suppose I get a coefficient like 19956694.3256

For my code, only the last digit of the quotient to decimal (i.e. 4) is important. The goal is to check if the quotient is even or odd and, if possible, the value of the last digit.

I cannot use simple DB functions like module or division, as it is very laborious. Is there a more efficient way? Any suggestions would be highly appreciated.

Thank you very much.

Relationship Neeraj

+3
source share
1 answer

What you want to do is pretty much the definition of "modulo arithmetic." If the built-in arithmetic in your database cannot perform the calculations quickly enough, I'm not sure what you could do to improve this without creating your own database engine or buying more powerful hardware.

Is the problem really arithmetic speed, or is it recording or indexing a record? I mean, if you say something like:

select ... whatever ... from table1 join table2 using (someid)
where (table1.q / table2.d) % 10 = 4

(table1.q/table2.d)% 10, , db , , , , .

+5

All Articles