Eg a=10, b=3
Excel = Mod(a,b) = 1
MB = a Mod b = 1
Are you trying to use it with integers or float values ?
Gentreau
As Gentreau says, it's the remainder of a division, and in MapInfo's
case, they limit it to working on integers only. So, for example, the
expression: 17 mod 3 is equal to 17\3 = 5, with a remainder of 2, so 17
mod 3 is 2. (And the '\' is not a typo; that's MapInfo's integer
division operator.)
What it does in a higher sense is limit numbers to fixed range of
possibilities from 0 up to, but not including the mod value. And believe
it or not, that can be very useful. Here's a MapInfo example. Suppose
you had a table of test results that you wanted to split into three
sample groups. First, you'd create an integer column for record id's
(let's call it 'id') and then you'd fill it using the SQL statement:
UPDATE MyTable SET id = rowid
Then using the mod operator, you could create a sample group number
associated with every record that would be either 0, 1, or 2 with a
select statement, like so:
SELECT id MOD 3 "Group_Id", col1, col2, ..., coln FROM MyTable INTO Samples
Now, with that group_id field attached to the Samples table, you can
choose records from any of 3 groups that you want.
It's also useful in programming when you want to split a MapInfo color
number into its red, green and blue components (e.g. if nColor is your
color code then nColor MOD 256 is the blue value, (nColor \ 256) MOD 256
is the green, and nColor \ 256^2 is the red). It's very useful in
cryptography too.
In the case of negative numbers, the result should be adjusted into the
range 0 <= mod n < n, so, for example,
-17 MOD 3 = -2 is what MapInfo gets, but it should be 1 ( because even
though -2 and 1 are congruent in the mod 3 domain, if you get a negative
number from a mod operation it's usually added to the mod number so that
the result is positive.
That's straight-forward, so long as the distances are reasonably short and
you don't want to be accurate within centimetres.
Just use standard trig and forget about great circles.
You need to know that 1 deg of latitude (y) ~ 111km
And that 1 deg of longitude (x) is ~ 111km * cos(latitude)
You know x1 and y1 (long & lat), the angle in degrees a and the distance in
metres d
x2 = (x1 + (d*sin(a)) / (111000 * cos(y1))
y2 = (y1 + (d*cos(a)) / 111000
You will need to convert angles to radians to use this in MapBasic, but
that's the basic calculation.
Hth
Gentreau.
-----Original Message-----
From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On
Behalf Of Glen
Sent: Friday, January 18, 2008 10:44 PM
To: MapInfo-L
Should read:
x2 = x1 + ((d*sin(a)) / (111000 * cos(y1)))
y2 = y1 + ((d*cos(a)) / 111000 )