From: "chris.danx" <chris.danx@ntlworld.com>
Subject: Re: Integer? float? confused...
Date: Tue, 20 Mar 2001 22:55:42 -0000
Date: 2001-03-20T22:55:42+00:00 [thread overview]
Message-ID: <MdRt6.14268$Q4.2662554@news2-win.server.ntlworld.com> (raw)
In-Reply-To: 998i7d$19j21@tech.port.ac.uk
You need to use 3.0, 6.0, 5.0 and 120.0 in function Calc_Sin. This is
because Ada requires a float to have decimal point in it somewhere. If you
don't include the .0 Ada thinks it's an integer. Also convert the Num to a
float by Float(Num) otherwise Ada thinks Num is an integer -- which it is!
but your can't mix types so you've got to convert.
May i make a suggestion? It would be better to have
function Calc_Sin (Num : integer) return float is
begin
return Num - (Num ** 3) / 6 + (Num ** 5) / 120;
end Calc_Sin
instead of using sin_result. This variable is global and in other programs
you might do something similar and it'll screw everything up. You could
move the declaration of Sin_Result inside the function and what you've
written would work if you fixed the type conversion problem. I haven't
fixed it in the above function cos' that's for you to do.
Hope this helps,
Chris Campbell
p.s. let me know *when* you get it working, or if anythings not clear -- i'm
terrible at explaining things to people.
next prev parent reply other threads:[~2001-03-20 22:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-03-20 21:31 Integer? float? confused WM
2001-03-20 22:55 ` chris.danx [this message]
2001-03-20 22:59 ` EtienneB
2001-03-21 1:32 ` Ken Garlington
2001-03-23 12:08 ` dis00109
-- strict thread matches above, loose matches on Subject: below --
2001-03-20 21:31 WM
2001-04-05 18:30 ` mark
2001-03-20 21:31 WM
2001-03-23 7:07 ` Sven Nilsson
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox