From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Ada and Java. different behaviour. casting long to int problem.
Date: 1999/06/17
Date: 1999-06-17T00:00:00+00:00 [thread overview]
Message-ID: <m3674n7427.fsf@mheaney.ni.net> (raw)
In-Reply-To: 3767D597.8C77A423@cajunbro.com
On 16 Jun 1999 11:49, "George W. Bayles" <georgeb@cajunbro.com> wrote:
> That reminds me - using scaled integers to represent angles
>
> int theta = (int) MAX_INT*(theta_degrees/180.0);
>
> makes adding and subtracting angles much nicer because of the wrap
> around! It is a feature of computer integers that they are more like a
> compass than a ruler.
You can do this in Ada already:
with System;
package Angle_Types is
type Angle_In_Deg_Type_Base is
delta 1024.0 * System.Fine_Delta
range -1024.0 .. 1024.0;
for Angle_In_Deg_Type_Base'Small use
1024.0 * System.Fine_Delta;
subtype Angle_In_Deg_Type is
Angle_In_Deg_Type_Base
range 0.0 .. Angle_In_Deg_Type_Base'Pred (360.0);
function "+" (L, R : Angle_In_Deg_Type)
return Angle_In_Deg_Type;
function "-" (L, R : Angle_In_Deg_Type)
return Angle_In_Deg_Type;
<other ops>
end Angle_Types;
The addition and substraction operators are defined to have wrap-around
semantics.
This captures the angle abstraction perfectly, and we don't have to go
mucking around with hacks like "scaled integers."
next prev parent reply other threads:[~1999-06-17 0:00 UTC|newest]
Thread overview: 120+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-12 0:00 Ada and Java. different behaviour. casting long to int problem nabbasi
1999-06-12 0:00 ` Tucker Taft
1999-06-12 0:00 ` PPAATT
1999-06-12 0:00 ` Keith Thompson
1999-06-12 0:00 ` kirck
1999-06-13 0:00 ` Robert Dewar
1999-06-12 0:00 ` Fred
1999-06-14 0:00 ` Mark Hood
1999-06-15 0:00 ` mike
1999-06-15 0:00 ` Samuel Mize
1999-06-15 0:00 ` jerry
1999-06-16 0:00 ` Richard D Riehle
1999-06-16 0:00 ` jerry
1999-06-15 0:00 ` D'Arcy Smith
1999-06-16 0:00 ` George W. Bayles
1999-06-16 0:00 ` D'Arcy Smith
1999-06-17 0:00 ` Matthew Heaney [this message]
1999-06-17 0:00 ` Aidan Skinner
1999-06-15 0:00 ` Marin David Condic
1999-06-15 0:00 ` Mike Silva
1999-06-15 0:00 ` rich
1999-06-15 0:00 ` Marin David Condic
1999-06-15 0:00 ` D'Arcy Smith
1999-06-15 0:00 ` Keith Thompson
1999-06-16 0:00 ` D'Arcy Smith
1999-06-16 0:00 ` bill
1999-06-16 0:00 ` George W. Bayles
1999-06-16 0:00 ` Fraser Wilson
1999-06-17 0:00 ` Aidan Skinner
1999-06-17 0:00 ` David Botton
1999-06-18 0:00 ` Dale Stanbrough
1999-06-18 0:00 ` Matthew Heaney
1999-06-18 0:00 ` David Botton
1999-06-18 0:00 ` Pascal Obry
1999-06-17 0:00 ` Chris Dollin
1999-07-20 0:00 ` Geoff Bull
1999-06-16 0:00 ` Marin David Condic
1999-06-16 0:00 ` Mike Silva
1999-06-16 0:00 ` D'Arcy Smith
1999-06-16 0:00 ` kirk
1999-06-16 0:00 ` D'Arcy Smith
1999-06-17 0:00 ` Markus Kuhn
1999-06-17 0:00 ` D'Arcy Smith
1999-06-17 0:00 ` john
1999-06-17 0:00 ` Ed Falis
1999-06-18 0:00 ` Aidan Skinner
1999-06-16 0:00 ` Hyman Rosen
1999-06-17 0:00 ` Robert I. Eachus
1999-06-17 0:00 ` Hyman Rosen
1999-06-17 0:00 ` bob
1999-06-18 0:00 ` Hyman Rosen
1999-06-18 0:00 ` mike
1999-06-18 0:00 ` Hyman Rosen
1999-06-19 0:00 ` Dale Stanbrough
1999-06-21 0:00 ` Marin David Condic
1999-06-19 0:00 ` Samuel Mize
1999-06-21 0:00 ` Marin David Condic
1999-06-21 0:00 ` Mike Silva
1999-06-17 0:00 ` Marin David Condic
1999-06-17 0:00 ` Markus Kuhn
1999-06-17 0:00 ` Jean-Pierre Rosen
1999-06-17 0:00 ` Marin David Condic
1999-06-17 0:00 ` Samuel Mize
1999-06-17 0:00 ` Marin David Condic
1999-06-22 0:00 ` Hyman Rosen
1999-06-22 0:00 ` Keith Thompson
1999-06-23 0:00 ` Marin David Condic
1999-06-24 0:00 ` Robert A Duff
1999-06-24 0:00 ` Marin David Condic
1999-06-23 0:00 ` Marin David Condic
1999-06-18 0:00 ` Aidan Skinner
1999-06-20 0:00 ` Sera Hirasuna
1999-06-19 0:00 ` Kio
1999-06-20 0:00 ` Vladimir Olensky
1999-06-21 0:00 ` Samuel T. Harris
1999-06-22 0:00 ` Robert I. Eachus
1999-06-23 0:00 ` Richard D Riehle
1999-06-23 0:00 ` Aidan Skinner
1999-06-22 0:00 ` Richard D Riehle
1999-06-21 0:00 ` Hyman Rosen
1999-06-17 0:00 ` Jean-Pierre Rosen
1999-06-16 0:00 ` George W. Bayles
1999-06-16 0:00 ` Tucker Taft
1999-06-17 0:00 ` George W. Bayles
1999-06-17 0:00 ` Tucker Taft
1999-06-17 0:00 ` bob
1999-06-16 0:00 ` D'Arcy Smith
1999-06-16 0:00 ` D'Arcy Smith
1999-06-17 0:00 ` Larry Kilgallen
1999-06-22 0:00 ` Robert Dewar
1999-06-23 0:00 ` Marin David Condic
1999-06-23 0:00 ` Vladimir Olensky
1999-06-23 0:00 ` Roedy Green
1999-06-23 0:00 ` Marin David Condic
1999-06-23 0:00 ` Keith Thompson
1999-06-24 0:00 ` Marin David Condic
1999-06-24 0:00 ` Mike Silva
1999-06-23 0:00 ` Marin David Condic
1999-06-15 0:00 ` tmoran
1999-06-15 0:00 ` David Botton
1999-06-16 0:00 ` Samuel Mize
1999-06-16 0:00 ` Richard D Riehle
1999-06-15 0:00 ` Samuel Mize
1999-06-16 0:00 ` Mark Hood
1999-06-17 0:00 ` Jean-Pierre Rosen
1999-06-17 0:00 ` Robert I. Eachus
1999-06-17 0:00 ` Marin David Condic
1999-06-17 0:00 ` Markus Kuhn
1999-06-17 0:00 ` David Botton
1999-06-13 0:00 ` Robert Dewar
1999-06-14 0:00 ` tmoran
1999-06-30 0:00 ` John Merryweather Cooper
1999-07-01 0:00 ` Chad R. Meiners
1999-07-02 0:00 ` Robert Dewar
1999-07-02 0:00 ` John Merryweather Cooper
1999-07-03 0:00 ` Robert Dewar
1999-06-12 0:00 ` nabbasi
1999-06-12 0:00 ` jerry
1999-06-12 0:00 ` Robert Dewar
1999-06-14 0:00 ` Marin David Condic
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox