Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: 0 illegal modulus?

by jepri (Parson)
on Jun 16, 2001 at 07:35 UTC ( #89002=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: 0 illegal modulus?
in thread 0 illegal modulus?

You say:

ps. why would I want to read a book on number theory to understand why a basic operator behaves the way it does?

The answer is "So you know what you are talking about". I admit I was too quick off the gun as well, however. After some further research I found that the modulo function was devised by Abel in the 1700's to allow him to study large and complicated groups with only pencil and paper.

Modulo is hardly a basic operator. It's just a basic operator for you because you've only ever used it in simple situations.

Computer implementations of functions are usually nasty bastardisations of real math functions. This is why the original poster mentioned Knuth, who did a lot of work involving math and computers.

Incidentally, 'proof by random web pages' is a poor way of proving that you are right.

I didn't believe in evil until I dated it.

Replies are listed 'Best First'.
Re: Re: 0 illegal modulus?
by mugwumpjism (Hermit) on Jun 18, 2001 at 13:16 UTC

    (On reading a book to understand a simple principle)

    You obviously don't get it. You can't expect someone who uses the % operator to have read a book on number theory first. Therefore it should behave intuitively and comply with what the commonly accepted understanding of the term is, so long as it is sensible and consistent. I think I have demonstrated in other posts that a modulus of 0 is neither sensible nor consistent, except with one contrived definition of modulus which I still think is bogus.

    You say a modulus is defined one way; I say another. Who is to say who is right, or whether being "right" means anything? Let's end this rant and agree to disagree.

      This is all so terribly familiar. I grew up programming (literally). Calculus at school was easy for me, because while the class was trying to understand what a function was, I was writing recursive ones. Simple simple simple. I taught myself math above my level so I could do tricks with my computer. I'm not boasting. The young monks here would have outshone me, but I was ahead of my classmates.

      Math was so easy. But looking back every so often someone would point out something that didn't quite fit, I would call them stupid and sneer at them (like you have repeatedly in this thread) and they would go away.

      It wasn't until I was taking advanced math at uni that I finally had it made completely clear to me what a twat I was being. The work was easy, except the lecturer kept focussing on stupid exceptions, like asymptotes, dividing functions in stupid situations, etc. The penny finally dropped that the real game was working with those exceptions, not the easy, 'intuitive' stuff.

      Your educators have not been completely forthcoming. Pretty much everything you are told is a gross over-simplification or half-truth. The more honest amoung them will tell you that you get the lite version.

      It would be possible for you to spend your whole life not understanding things better by belittling and attacking anyone who disagrees with you. This would be a shame, because it seems you are the kind of person who would get a kick out of the tougher stuff. Group theory might not be the best place to start, but it is relevent to many programs and techniques, so you would quickly begin to see it all over the place.

      I would encourage you to start looking at things a bit more closely, with the thought in mind 'Why do people care so much about this?'. Often there's a reason, it's just hard to understand when you come at it from a different angle to most people who use it. Feel free to ask questions that are a bit 'off-topic', there's an amazing body of knowledge here.

      I didn't believe in evil until I dated it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://89002]
[jdporter]: one prog I have has a UI which allows to input a bit mask
[jdporter]: currently it expects the bitmask to be in the form of a hex number, e.g. 0x0101
[jdporter]: but I'd like to let the user specify it as individual bits, i.e. 0b0000000100000001
[jdporter]: there is no bit/binary equivalent of hex, right?
[jdporter]: I guess that the most direct way of doing it is with some magical incantation involving unpack or whatever
[jdporter]: let me google that for me ;-)
[jdporter]: hex points explicitly to oct, which does the job. :-D
[jdporter]: omg, I f love Perl!
[choroba]: say unpack 'H*', pack 'B*', $mask =~ /0b([01]+)/;

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (11)
As of 2018-02-20 16:32 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (272 votes). Check out past polls.