comp.lang.ada
 help / color / mirror / Atom feed
* Re: Intel-OA: Using 'floor on float data type
       [not found] <9902021551.AA12360@ce101.ce.memphis.edu>
@ 1999-02-02  0:00 ` Hugh 'Huge' O'Donnell
  0 siblings, 0 replies; only message in thread
From: Hugh 'Huge' O'Donnell @ 1999-02-02  0:00 UTC (permalink / raw)
  To: Orville E. Wheeler

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;




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-02-02  0:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <9902021551.AA12360@ce101.ce.memphis.edu>
1999-02-02  0:00 ` Intel-OA: Using 'floor on float data type Hugh 'Huge' O'Donnell

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