Wrapping matrix
Wrapping matrix
- Subject: Wrapping matrix
- From: Andrew Merenbach <email@hidden>
- Date: Mon, 14 Apr 2003 18:04:26 -0700
I'm in the process of making a life-simulator, and have pretty much
everything implemented--except for a method that will check the
neighbors of a cell. I wish a certain macro--call it translateRow(row,
x, totalRows)--to translate the number row by x--but if x >= totalRows,
or x < 0, I wish it to "wrap around." I accomplished this fairly
easily through the use of the percent operator, but have a slight
problem, in that negative numbers appear to foul it up. Thus (-1)%6
returns -1, rather than 5. This appears to me to be an actual
calculation error in the basic operation of the compiler--has anyone an
idea of a workaround, short of defining my own modulo function (a - b *
floor(a/b))?
Take care,
Andrew
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.