From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_05,INVALID_DATE, PLING_QUERY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,329032975b221f1,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-09-29 06:15:44 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!usc!elroy.jpl.nasa.gov!decwrl!netcomsv!butch!pong.lasc.lockheed.com!deepthought!tony From: tony@deepthought.Sgi.COM (Tony Leavitt) Newsgroups: comp.lang.ada Subject: Q: common types?! Date: 28 Sep 1994 15:16:16 GMT Organization: Silicon Graphics, Inc. Sender: tony@deepthought (Tony Leavitt) Distribution: world Message-ID: <36c1c0$lve@pong.lasc.lockheed.com> NNTP-Posting-Host: deepthought.lasc.lockheed.com Date: 1994-09-28T15:16:16+00:00 List-Id: I have a question for all you Ada wizards. I do not have a lot of experience with Ada (only about 3000 lines), and I have begun to start making a common types package. This package would define all kinds of types for feet, nautical miles, degrees, radians, etc, ad nuasium, for all different kinds and sizes of float and integers. Am I about to go insane by trying this? Or, does this exist already on the Internet somewhere? If I was to attempt to do this how would you recommend about doing it? Here is a sample of what I started to do: package Common_Types is type float64 is new float ; for float64'SIZE use 64 ; type float32 is new float ; for float32'SIZE use 32 ; type integer64 is new integer ; for integer64'SIZE use 64 ; type integer32 is new integer ; for integer32'SIZE use 32 ; type integer16 is new integer ; for integer16'SIZE use 16 ; type integer8 is new integer ; for integer8'SIZE use 8 ; ---------------------------------------------------------------------------- -- Linear Distance Types ---------------------------------------------------------------------------- FEET_PER_NAUTICAL_MILE : constant float := 6076.115 ; FEET_PER_STATUTE_MILE : constant float := 5280.0 ; FEET_PER_KILOMETER : constant float := 3280.8399 ; FEET_PER_METER : constant float := 3.2808399 ; type Nautical_Miles_f64 is new float64 ; subtype NM_f64 is Nautical_Miles_f64 ; type Nautical_Miles_f32 is new float32 ; subtype NM_f32 is Nautical_Miles_f32 ; type Nautical_Miles_i64 is new integer64 ; subtype NM_i64 is Nautical_Miles_i64 ; type Nautical_Miles_i32 is new integer32 ; subtype NM_i32 is Nautical_Miles_i32 ; type Nautical_Miles_i16 is new integer16 ; subtype NM_i16 is Nautical_Miles_i16 ; type Nautical_Miles_i8 is new integer8 ; subtype NM_i8 is Nautical_Miles_i8 ; type Statute_Miles_f64 is new float64 ; subtype MI_f64 is Statute_Miles_f64 ; type Statute_Miles_f32 is new float32 ; subtype MI_f32 is Statute_Miles_f32 ; type Statute_Miles_i64 is new integer64 ; subtype MI_i64 is Statute_Miles_i64 ; type Statute_Miles_i32 is new integer32 ; subtype MI_i32 is Statute_Miles_i32 ; type Statute_Miles_i16 is new integer16 ; subtype MI_i16 is Statute_Miles_i16 ; type Statute_Miles_i8 is new integer8 ; subtype MI_i8 is Statute_Miles_i8 ; type Feet_f64 is new float64 ; subtype FT_f64 is Feet_f64 ; type Feet_f32 is new float32 ; subtype FT_f32 is Feet_f32 ; type Feet_i64 is new integer64 ; subtype FT_i64 is Feet_i64 ; type Feet_i32 is new integer32 ; subtype FT_i32 is Feet_i32 ; type Feet_i16 is new integer16 ; subtype FT_i16 is Feet_i16 ; type Feet_i8 is new ---------------------------------------------------------------------------- -- Angular Distance Types ---------------------------------------------------------------------------- type Degrees_f64 is new float64 ; type Degrees_f32 is new float32 ; -- same for radians. ---------------------------------------------------------------------------- -- Earth Position Types ---------------------------------------------------------------------------- subtype Latitude_f64 is Degrees_f64 range -90.0 .. +90.0 ; subtype Latitude_f32 is Degrees_f32 range -90.0 .. +90.0 ; -- Same for Longitude, heading, bearing, etc ---------------------------------------------------------------------------- -- Functions ---------------------------------------------------------------------------- function sin ( x : Degrees_f64 ) return float64 ; function sin ( x : Degrees_f32 ) return float32 ; function sin ( x : Radians_f64 ) return float64 ; function sin ( x : Radians_f32 ) return float32 ; function convert (x : degrees_f64) return degrees_32 ; function convert (x : radians_f64) return degrees_i16 ; -- etc, etc, etc, etc, until you puke. Same for operators "*", and "+" which -- would do all kinds of type conversion and make sure the units are protected. end Common_Types ; -- Tony Leavitt Lockheed Aeronautical Systems Company Marietta, GA 30063-0670 Voice: (404) 494-7648, Fax:(404) 494-6989 Email: tony@gelac.lasc.lockheed.com