Click here to Skip to main content
15,891,136 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Sometimes Pin
OriginalGriff25-Aug-15 8:06
mveOriginalGriff25-Aug-15 8:06 
GeneralRe: Sometimes Pin
Afzaal Ahmad Zeeshan25-Aug-15 8:41
professionalAfzaal Ahmad Zeeshan25-Aug-15 8:41 
GeneralRe: Sometimes Pin
CDP180225-Aug-15 8:09
CDP180225-Aug-15 8:09 
GeneralRe: Sometimes Pin
Afzaal Ahmad Zeeshan25-Aug-15 8:38
professionalAfzaal Ahmad Zeeshan25-Aug-15 8:38 
GeneralRe: Sometimes Pin
Slacker00725-Aug-15 9:13
professionalSlacker00725-Aug-15 9:13 
GeneralRe: Sometimes Pin
Afzaal Ahmad Zeeshan25-Aug-15 9:18
professionalAfzaal Ahmad Zeeshan25-Aug-15 9:18 
GeneralRe: Sometimes Pin
Slacker00725-Aug-15 9:25
professionalSlacker00725-Aug-15 9:25 
GeneralTuesday Coding Challenge Pin
harold aptroot25-Aug-15 9:33
harold aptroot25-Aug-15 9:33 
Yes, because you can make a better wheel.

Tuesday Coding Challenge: do a modular multiplication of two ulongs, modulo some ulong, imagine (x * y) % m using BigInteger. You may assume that x < m && y < m && m != 0 because not assuming that just adds some trivial preprocessing and doesn't change the core of the problem.
Go do it in C#. If you don't use BigInteger, I'm sure you already see the trouble coming: you can't even multiply two ulongs in such a way that you get the upper half, so you'd have to split them, and the division is even more annoying.
Or if you use BigInteger as in the example, sure, that works.. but it has to do the same thing internally so it still sucks - you've hidden the suck but that doesn't make it go away. One of the biggest failings of high level languages IMO, you can just sweep the suck under the rug, making it too easy to just ignore it.
Or you could do a longhand binary multiplication so you can sneak in reductions one by one, but that's obviously terrible.

In x64 assembly it's:
ASM
mov rax, rcx
mul rdx
div r8
mov rax, rdx
ret
So C# is really annoying here, there's a perfectly fine feature available in the processor to do this easily and somewhat efficiently (128-by-64bit division still sucks, but not as much as when you emulate it), but you can't use it so you're reduced to doing it in dumb and annoying ways.

edit: forgot a mov.

modified 25-Aug-15 15:42pm.

GeneralRe: Tuesday Coding Challenge Pin
F-ES Sitecore25-Aug-15 11:18
professionalF-ES Sitecore25-Aug-15 11:18 
GeneralRe: Tuesday Coding Challenge Pin
harold aptroot25-Aug-15 11:55
harold aptroot25-Aug-15 11:55 
QuestionRe: Tuesday Coding Challenge Pin
Eddy Vluggen25-Aug-15 12:39
professionalEddy Vluggen25-Aug-15 12:39 
GeneralRe: Tuesday Coding Challenge Pin
harold aptroot25-Aug-15 22:33
harold aptroot25-Aug-15 22:33 
JokeRe: Sometimes Pin
Johnny J.25-Aug-15 19:44
professionalJohnny J.25-Aug-15 19:44 
GeneralRe: Sometimes Pin
Kirk 1038982127-Aug-15 3:45
Kirk 1038982127-Aug-15 3:45 
GeneralRe: Sometimes Pin
Afzaal Ahmad Zeeshan27-Aug-15 3:48
professionalAfzaal Ahmad Zeeshan27-Aug-15 3:48 
GeneralThought of the day Pin
OriginalGriff25-Aug-15 4:52
mveOriginalGriff25-Aug-15 4:52 
GeneralRe: Thought of the day Pin
W Balboos, GHB25-Aug-15 4:54
W Balboos, GHB25-Aug-15 4:54 
GeneralRe: Thought of the day Pin
PIEBALDconsult25-Aug-15 5:04
mvePIEBALDconsult25-Aug-15 5:04 
GeneralRe: Slightly OT... PinPopular
Jeremy Falcon25-Aug-15 5:06
professionalJeremy Falcon25-Aug-15 5:06 
GeneralRe: Thought of the day Pin
jeron125-Aug-15 5:09
jeron125-Aug-15 5:09 
GeneralRe: Thought of the day Pin
Ravi Bhavnani25-Aug-15 5:11
professionalRavi Bhavnani25-Aug-15 5:11 
GeneralRe: Thought of the day Pin
jeron125-Aug-15 5:22
jeron125-Aug-15 5:22 
GeneralRe: Thought of the day Pin
Ravi Bhavnani25-Aug-15 5:23
professionalRavi Bhavnani25-Aug-15 5:23 
GeneralRe: Thought of the day Pin
Jeremy Falcon25-Aug-15 5:27
professionalJeremy Falcon25-Aug-15 5:27 
GeneralRe: Thought of the day Pin
Ravi Bhavnani25-Aug-15 5:40
professionalRavi Bhavnani25-Aug-15 5:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.