comp.lang.ada
 help / color / mirror / Atom feed
* Working with Scaled Integers
@ 2001-10-13 23:31 Andrew
  2001-10-13 23:38 ` R. Tim Coslet
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew @ 2001-10-13 23:31 UTC (permalink / raw)


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







^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Working with Scaled Integers
  2001-10-13 23:31 Working with Scaled Integers Andrew
@ 2001-10-13 23:38 ` R. Tim Coslet
  2001-10-14  0:59   ` Andrew
  0 siblings, 1 reply; 5+ messages in thread
From: R. Tim Coslet @ 2001-10-13 23:38 UTC (permalink / raw)


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




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Working with Scaled Integers
  2001-10-13 23:38 ` R. Tim Coslet
@ 2001-10-14  0:59   ` Andrew
  2001-10-14 13:33     ` Jeff Creem
  2001-10-16 14:58     ` Stephen Leake
  0 siblings, 2 replies; 5+ messages in thread
From: Andrew @ 2001-10-14  0:59 UTC (permalink / raw)


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
>




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Working with Scaled Integers
  2001-10-14  0:59   ` Andrew
@ 2001-10-14 13:33     ` Jeff Creem
  2001-10-16 14:58     ` Stephen Leake
  1 sibling, 0 replies; 5+ messages in thread
From: Jeff Creem @ 2001-10-14 13:33 UTC (permalink / raw)


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
> >
>





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Working with Scaled Integers
  2001-10-14  0:59   ` Andrew
  2001-10-14 13:33     ` Jeff Creem
@ 2001-10-16 14:58     ` Stephen Leake
  1 sibling, 0 replies; 5+ messages in thread
From: Stephen Leake @ 2001-10-16 14:58 UTC (permalink / raw)


"Andrew" <mysig@fast.net> writes:

> We are tied to using existing types because our package specs are generated
> by tools.

Hmm. This raises two questions.

1) If the tool writes the code for you, why do you need to
  "understand" it better? I suppose you don't trust the tool; probably
  wise.

2) If the tool claims to be generating Ada code, but is not using
   fixed point types for scaled integers, it is broken. It probably
   also supports C output, but that's no excuse! Time for a new tool.

> 
> 
> --------------------------------------------------------------
> 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
> >
> 

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2001-10-16 14:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2001-10-16 14:58     ` Stephen Leake

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