comp.lang.ada
 help / color / mirror / Atom feed
* What this program is going to do?
@ 2003-07-24  7:39 prashna
  2003-07-24  8:12 ` Samuel Tardieu
  0 siblings, 1 reply; 4+ messages in thread
From: prashna @ 2003-07-24  7:39 UTC (permalink / raw)


function PART_ENT (
         X : in     FLOAT ) 
     return FLOAT is 
      R : FLOAT;  
   begin
      -- Attention imprecision pour .5
      R := FLOAT (INTEGER (abs X));

      -- Round to Zero afin de corriger l'imprecision
      if R > abs X then
         R := R - 1.0;
      end if;

      -- Signe du resultat
      if X >= 0.0 then
         return R;
      else
         return - R;
      end if;
   end PART_ENT;
I found this program in source code of my project(code review).Can any
one explain what this program does?



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

* Re: What this program is going to do?
  2003-07-24  7:39 What this program is going to do? prashna
@ 2003-07-24  8:12 ` Samuel Tardieu
  2003-07-24 16:47   ` Richard Riehle
  0 siblings, 1 reply; 4+ messages in thread
From: Samuel Tardieu @ 2003-07-24  8:12 UTC (permalink / raw)


>>>>> "prashna" == prashna  <vashwath@rediffmail.com> writes:

prashna> I found this program in source code of my project(code
prashna> review).Can any one explain what this program does?

Excuse me for being rude, but if you can't figure yourself what this
function does, you are certainly not qualified to participate in a
code review (except as a person whose code is being reviewed but it
does not look like it's your code here).

This function returns the integer part of the floating point
variable. It does the same thing as:

function Integer_Part (X : Float) is
begin
  if X >= 0.0 then
    return Float'Floor (X);
  else
    return Float'Ceiling (X);
  end if;
end Integer_Part;

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/sam



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

* Re: What this program is going to do?
  2003-07-24  8:12 ` Samuel Tardieu
@ 2003-07-24 16:47   ` Richard Riehle
  2003-07-24 22:22     ` Samuel Tardieu
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Riehle @ 2003-07-24 16:47 UTC (permalink / raw)


Samuel Tardieu wrote:

> >>>>> "prashna" == prashna  <vashwath@rediffmail.com> writes:
>
> prashna> I found this program in source code of my project(code
> prashna> review).Can any one explain what this program does?
>
> Excuse me for being rude, but if you can't figure yourself what this
> function does, you are certainly not qualified to participate in a
> code review (except as a person whose code is being reviewed but it
> does not look like it's your code here).
>
> This function returns the integer part of the floating point
> variable. It does the same thing as:
>
> function Integer_Part (X : Float) is
> begin
>   if X >= 0.0 then
>     return Float'Floor (X);
>   else
>     return Float'Ceiling (X);
>   end if;
> end Integer_Part;

Sam.  I hate to be a nitpicker, but your function has not return type.

Richard Riehle




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

* Re: What this program is going to do?
  2003-07-24 16:47   ` Richard Riehle
@ 2003-07-24 22:22     ` Samuel Tardieu
  0 siblings, 0 replies; 4+ messages in thread
From: Samuel Tardieu @ 2003-07-24 22:22 UTC (permalink / raw)


>>>>> "Richard" == Richard Riehle <richard@adaworks.com> writes:

Richard> Sam.  I hate to be a nitpicker, but your function has not
Richard> return type.

You're right, I typed it directly in my news client and forgot this
one. Hopefully, the astute reader would have added "return Float"
by himself :)

  Sam
-- 
Samuel Tardieu -- sam@rfc1149.net -- http://www.rfc1149.net/sam



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

end of thread, other threads:[~2003-07-24 22:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-24  7:39 What this program is going to do? prashna
2003-07-24  8:12 ` Samuel Tardieu
2003-07-24 16:47   ` Richard Riehle
2003-07-24 22:22     ` Samuel Tardieu

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