comp.lang.ada
 help / color / mirror / Atom feed
From: Hugh 'Huge' O'Donnell <hugehugh@geocities.com>
To: "Orville E. Wheeler" <gene@ce101.ce.memphis.edu>
Subject: Re: Intel-OA: Using 'floor on float data type
Date: 1999/02/02
Date: 1999-02-03T02:54:31+00:00	[thread overview]
Message-ID: <36B7B9A4.446A20BF@geocities.com> (raw)
In-Reply-To: 9902021551.AA12360@ce101.ce.memphis.edu

Hello, 

This is how I fixed the problem with 'floor:

type Index_Float is digits 10;

Temp := Index_Float(Hypo.Score.Purity) * Index_Float(Num_Bins);
Purity_Index := Integer(Index_Float'Floor(Temp) + 1.0);

It appears that 'floor is an attribute of the type (Index_Float) that
takes the variable in question as a parameter.  The result must be type
casted if an integer result is desired.  

If you look in Ada 95 LRM Section A.5.3:

The following primitive function attributes are defined for any subtype
S of a floating point type T. ....

S�Floor denotes a function with the following specification:

function S'Floor (X : T) return T

An actual example of how to use this is found in Cohen's Ada as a Second
Language on approximately pg 125.  

Thanks for your help,

Hugh O'Donnell            

"Orville E. Wheeler" wrote:
> 
> >Purity_Index := Index_Float(Temp)'Floor + 1;
> 
> Try
> 
>   Purity_Index := Index_Float(Temp)'Floor + 1.0;




           reply	other threads:[~1999-02-02  0:00 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <9902021551.AA12360@ce101.ce.memphis.edu>]
replies disabled

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