comp.lang.ada
 help / color / mirror / Atom feed
* sign bit for digits type
@ 1997-02-11  0:00 luo
  1997-02-12  0:00 ` David Taylor
  1997-02-12  0:00 ` Mats Weber
  0 siblings, 2 replies; 3+ messages in thread
From: luo @ 1997-02-11  0:00 UTC (permalink / raw)



Subject: sign bit for digits type
Newsgroups: comp.lang.ada
Organization: Cyber Access Internet Communications, Inc.
Summary: 
Keywords: 

I have a float type as follows:

package A is
   type float_32 is digits 6;
end A;

This type is unsigned as defined by the language or the compiler?
I declare an object and a '-' operator as follows to handle negative
numbers:

with A;
package B is
  function "-" (x, y : A.float_32) renames A."-" return A.float_32;
  Real :A.float_32 := -5.0;
end B;

What happens in procedure C when I do the following:
with A;
with B;
procedure C is
  value : A.float_32 := B.Real;
begin
  null;
end C;

What is value equal to, 5.0 or -5.0?
Is this compiler dependent?

TIA.





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

* Re: sign bit for digits type
  1997-02-11  0:00 sign bit for digits type luo
  1997-02-12  0:00 ` David Taylor
@ 1997-02-12  0:00 ` Mats Weber
  1 sibling, 0 replies; 3+ messages in thread
From: Mats Weber @ 1997-02-12  0:00 UTC (permalink / raw)



> This type is unsigned as defined by the language or the compiler?

It is signed as defined by the language, as are all floating point types
in Ada (83 or 95).




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

* Re: sign bit for digits type
  1997-02-11  0:00 sign bit for digits type luo
@ 1997-02-12  0:00 ` David Taylor
  1997-02-12  0:00 ` Mats Weber
  1 sibling, 0 replies; 3+ messages in thread
From: David Taylor @ 1997-02-12  0:00 UTC (permalink / raw)



luo@cybercom.net wrote:
<<snip>> 
> package A is
>    type float_32 is digits 6;
> end A;

> with A;
> package B is
>   function "-" (x, y : A.float_32) renames A."-" return A.float_32;
>   Real :A.float_32 := -5.0;
> end B;
> 
> with A;
> with B;
> procedure C is
>   value : A.float_32 := B.Real;
> begin
>   null;
> end C;
> 
> What is value equal to, 5.0 or -5.0?
> TIA.

You clearly didn't compile this.  The line:

function "-" (x, y : A.float_32) renames A."-" return A.float_32;

has incorrect syntax and also doesn't do what you want it to do.  You need a "unary" minus:

function "-" (x : A.float_32)  return A.float_32 renames A."-";

So, Value should be -5.0. 

Dave Taylor




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

end of thread, other threads:[~1997-02-12  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-02-11  0:00 sign bit for digits type luo
1997-02-12  0:00 ` David Taylor
1997-02-12  0:00 ` Mats Weber

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