Shop OBEX P1 Docs P2 Docs Learn Events
integer remainder? — Parallax Forums

integer remainder?

yarisboyyarisboy Posts: 245
edited 2009-08-24 20:10 in Propeller 1
On page 260 of the manual I'm looking at "//" modulus. The example text talks about an "integer remainder". Looks like a real oxymoron. The remainder cited is .25. The example doesn't say if it is assigned as zero to x. In traditional PLC math .25 would store as a zero when assigned to an integer. If it is stored as .25 what data type is it? One more sentence: X is set equal to zero would make it clear, if that is the correct guess as to the result here. I looked up modulus in the dictionary. That was no help.

P.S. the book says: " If Y started out as 5 then y//4 equals 1, meaning the division of 5 by 4 results in a real real remainder whose
fractional component equals 1/4, or .25.

I'm terminally L.D.

Try this. After "equals 1" insert "and 1 is assigned to X." This finishes the description of what actually happens when using this code. If there are 4 sectors on the wheel and we made it all the way around the wheel plus .25 revolutions then we have .25 (the remainder) times 4 sectors per revolution equals 1.

Post Edited (yarisboy) : 8/24/2009 9:14:30 PM GMT

Comments

  • TimmooreTimmoore Posts: 1,031
    edited 2009-08-24 15:16
    y := x//z
    is the same as

    a := x/z
    y := x - a*z
    when doing int / and *
  • yarisboyyarisboy Posts: 245
    edited 2009-08-24 15:39
    In English does this mean we start with two integers, divide two of them resulting in an irrational number greater than 1, then throw away the part less than one before assigning the result to the desired Y?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-08-24 16:01
  • yarisboyyarisboy Posts: 245
    edited 2009-08-24 20:10
    Thanks, I got over the mod definition as soon as I figured out what the object author is doing. The best help is the calculator in ubuntu linux. I can enter any base number and convert. I'm also fully commenting the code I'm studying as I go. Once you start beating it around in hex you see why the system is structured as it is. None of the numbers came out of thin air. Each has a reason. Each reserved word seems to have three meanings depending on context. Its been decades since I was baffled by "new math" but an angle vector of 362 degrees is the same as 2 degrees when ignoring the fourth dimension.

    Post Edited (yarisboy) : 8/24/2009 8:21:30 PM GMT
Sign In or Register to comment.