Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I found a project mono/decimal.c at ee90d5ff1d521f92c3dd9cca79b002dc4bc65ee3 · mono/mono · GitHub[^] where there are methods of mathematical operations with different values. But I need help with a row
C++
sub192(rlo, rmi, rhi, 0, tlo, thi, &rlo, &rmi, &rhi);

in the div192by96to32withRest method.

Why is the 4th parameter 0 rather than tlo?

It would probably be best if someone had a link to an explained code with division of large numbers.


What I have tried:

I tried to understand it, but I couldn't figure it out
Posted
Updated 4-Jul-21 18:00pm
v4
Comments
Richard MacCutchan 4-Jul-21 12:54pm    
Ask the person who wrote the code. We have no idea what the sub192 function is supposed to do, or what any of those 9 parameters represent.
KarNullKa 4-Jul-21 13:32pm    
I thought someone could look at the logic of the methods, they're not that long and it's not a long chain either, just division method calling another. Anyway, I thought it was quicker to ask than to try to contact the author of a several years old project. Alternatively, similar (better) examples would be useful, from which I can hopefully understand the logic.
Dave Kreskowiak 4-Jul-21 14:33pm    
Yeah, the method code is short but that doesn't tell you anything at all about the context they are used in.

There is a lot more work to figuring out that code than just looking at the method code.
KarNullKa 4-Jul-21 23:56pm    
When I was looking for something, I found question and the top rated answer had a link to this project as an example. Addition, subtraction and multiplication is not a problem, just in dividing that one row. I thought the author was using some "standard" solution that someone else could explain, probably not.
I needed a solution quickly, so I solved it this way, rather than waiting to see if and when the author would respond. I figured that for people who have experience with this, it's a similarly simple question to asking how a for loop works and will lead to a quick solution. I don't want to ask anyone to read a lot of code, but the part I asked about is 30 short lines. When I look at the other answered questions, they are often longer.
CHill60 6-Jul-21 11:01am    
"but the part I asked about is 30 short lines. " - but I can't see those 30 short lines because you didn't include the relevant code in your question. A lot of us drop by here in our breaks while at work, and github is blocked at my place of work.

To answer that, we'd have to do all the donkey work - a good hard look at what is a pretty-much undocumented project that few of us would have much need for. Why would you assume we'd want to do that for no good reason?

Ask the original author: if he doesn't respond, abandon it and move on.
 
Share this answer
 
The line I asked about is correct.It doesn't subtract the same parameters like lo, mid, hi because the values need to be shifted to subtract the highest part of the number. Therefore, the method sub192(rlo, rmi, rhi, 0, tlo, thi, &rlo, &rmi, &rhi) adds rlo-0, rmi-tlo and rhi-thi.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900