comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeff Creem" <jeff@thecreems.com>
Subject: Re: Working with Scaled Integers
Date: Sun, 14 Oct 2001 13:33:22 GMT
Date: 2001-10-14T13:33:22+00:00	[thread overview]
Message-ID: <Cugy7.112083$vq.25053484@typhoon.ne.mediaone.net> (raw)
In-Reply-To: tshodl6t9u8ga3@corp.supernews.com

This is a bit heavy but I have always done this sort of thing (1553 scaled
integers) by making
the type that is part of the 1553 message a private type and then having
fixed point (or
other appropriate type) visible in the spec with conversions defined between
the private
and the non-private type. I've done this for several (some of them probably
bad) reasons
including:

1) Compilers are not required to support fixed point types with 'smalls of
anything other
than an inverse power of two. By making my actual message type private and
then
declaring a fixed point type that has the same valid range but better a
finer 'small
I can basically work around this (in most cases)

2) The only compiler I've seen so far that does biased fixed point types is
GNAT. I like
it but I've never been able to use a compiler that supports it
(e.g.
type M_Type is range delta 0.5 range 1.0 .. 1.5;
for M_Type'small use 0.5;
for M_Type'size use 1;
) -- Note, I did not just try to compile the above...Probably full of
errors.


There are times when you get a message spec that requires types the above
so the private/public approach can be used to have the public type not have
a 1 bit
size and yet still enforce range checks.

3) Occasional bugs in fixed point types in some (now) very old Ada 83
compilers).


Now, you mention that your specs are machine generated so I am not clear
what we
have to work with and what LSBs you are trying to set.

Perhaps you can post a few line snippet and we can help.

"Andrew" <mysig@fast.net> wrote in message
news:tshodl6t9u8ga3@corp.supernews.com...
> We are tied to using existing types because our package specs are
generated
> by tools.
>
> --------------------------------------------------------------
> Andrew
>
>
>
> "R. Tim Coslet" <rtcoslet@pacbell.net> wrote in message
> news:3BC8D083.E6503BC3@pacbell.net...
> > Instead of "scaled integers" look at Ada's Fixed Point real types.
> >
> > For "BCD" types use Ada's Decimal types.
> >
> > Andrew wrote:
> >
> > > Developing/maintaining Ada code that processes 1553 bus data. I have a
> basic
> > > understanding of working with scaled integers. But I'd like to learn
> more.
> > > Specifically, working with semi-circles, how to specify data
resolution
> > > (LSB), BCD  etc. My understanding in this area is somewhat weak and I
> need
> > > to correct it.
> > >
> > > thanks;
> > >
> > > --------------------------------------------------------------
> > > Andrew
> >
>





  reply	other threads:[~2001-10-14 13:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-13 23:31 Working with Scaled Integers Andrew
2001-10-13 23:38 ` R. Tim Coslet
2001-10-14  0:59   ` Andrew
2001-10-14 13:33     ` Jeff Creem [this message]
2001-10-16 14:58     ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox