comp.lang.ada
 help / color / mirror / Atom feed
* Exponent floats?
@ 2005-03-28  4:49 Puckdropper
  2005-03-28  6:39 ` tmoran
  2005-03-28  6:49 ` Dmitry A. Kazakov
  0 siblings, 2 replies; 11+ messages in thread
From: Puckdropper @ 2005-03-28  4:49 UTC (permalink / raw)


I have an algorithm that requires a floating point exponent.  How can I 
use such a thing?  I tried using **, but it gives me 3 errors:

test.adb:12:24: invalid operand types for operator "**"
test.adb:12:24: left operand has type "Standard.float"
test.adb:12:24: right operand has type "Standard.float"

To demonstrate my problem, I wrote a short program:

-----------------------------

with Ada.Text_IO, Ada.Float_Text_IO;

procedure test is

expon: float;
Answer: float;
Base: float;

begin -- Main Program
	expon := 2.0;
	Base := 2.0;
	Answer := base ** expon;
	Ada.Float_Text_IO.put(Answer);
	Ada.Text_IO.new_line;
end test;

------------------------------

Thanks,

Puckdropper
-- 
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we 
still enjoy using the old computers. Sometimes we want to see how far a 
particular system can go, other times we use a stock system to remind 
ourselves of what we once had.

To email me directly, send a message to puckdropper (at) fastmail.fm



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

* Re: Exponent floats?
  2005-03-28  4:49 Exponent floats? Puckdropper
@ 2005-03-28  6:39 ` tmoran
  2005-03-28  6:49 ` Dmitry A. Kazakov
  1 sibling, 0 replies; 11+ messages in thread
From: tmoran @ 2005-03-28  6:39 UTC (permalink / raw)


> I have an algorithm that requires a floating point exponent.  How can I
> use such a thing?
You probably want function "**" in package Ada.Numerics.Elementary_Functions



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

* Re: Exponent floats?
  2005-03-28  4:49 Exponent floats? Puckdropper
  2005-03-28  6:39 ` tmoran
@ 2005-03-28  6:49 ` Dmitry A. Kazakov
  2005-03-28  8:49   ` Pascal Obry
  1 sibling, 1 reply; 11+ messages in thread
From: Dmitry A. Kazakov @ 2005-03-28  6:49 UTC (permalink / raw)


On Mon, 28 Mar 2005 04:49:40 GMT, Puckdropper wrote:

> I have an algorithm that requires a floating point exponent.  How can I 
> use such a thing?  I tried using **, but it gives me 3 errors:
> 
> test.adb:12:24: invalid operand types for operator "**"
> test.adb:12:24: left operand has type "Standard.float"
> test.adb:12:24: right operand has type "Standard.float"
> 
> To demonstrate my problem, I wrote a short program:
> 
> -----------------------------
> 
> with Ada.Text_IO, Ada.Float_Text_IO;

with Ada.Numerics.Elementary_Functions;
use  Ada.Numerics.Elementary_Functions;

> procedure test is
> 
> expon: float;
> Answer: float;
> Base: float;
> 
> begin -- Main Program
> 	expon := 2.0;
> 	Base := 2.0;
> 	Answer := base ** expon;

Answer := exp (log (base) * expon);

> 	Ada.Float_Text_IO.put(Answer);
> 	Ada.Text_IO.new_line;
> end test;

("**" is predefined for only integer powers, see ARM 4.5.6)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Exponent floats?
  2005-03-28  6:49 ` Dmitry A. Kazakov
@ 2005-03-28  8:49   ` Pascal Obry
  2005-03-28  9:57     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 11+ messages in thread
From: Pascal Obry @ 2005-03-28  8:49 UTC (permalink / raw)



"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> with Ada.Numerics.Elementary_Functions;
> use  Ada.Numerics.Elementary_Functions;

Ok.

> > procedure test is
> > 
> > expon: float;
> > Answer: float;
> > Base: float;
> > 
> > begin -- Main Program
> > 	expon := 2.0;
> > 	Base := 2.0;
> > 	Answer := base ** expon;
> 
> Answer := exp (log (base) * expon);

No, No need to change that, see below...

> > 	Ada.Float_Text_IO.put(Answer);
> > 	Ada.Text_IO.new_line;
> > end test;
> 
> ("**" is predefined for only integer powers, see ARM 4.5.6)

Yes, but "**" on floats is defined in Ada.Numerics.Elementary_Functions.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



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

* Re: Exponent floats?
  2005-03-28  8:49   ` Pascal Obry
@ 2005-03-28  9:57     ` Dmitry A. Kazakov
  2005-03-28 17:47       ` Puckdropper
  0 siblings, 1 reply; 11+ messages in thread
From: Dmitry A. Kazakov @ 2005-03-28  9:57 UTC (permalink / raw)


On 28 Mar 2005 10:49:27 +0200, Pascal Obry wrote:

> Yes, but "**" on floats is defined in Ada.Numerics.Elementary_Functions.

Yep, I forgot about it. 

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Exponent floats?
  2005-03-28  9:57     ` Dmitry A. Kazakov
@ 2005-03-28 17:47       ` Puckdropper
  2005-03-28 18:34         ` Pascal Obry
  2005-03-28 18:51         ` Dmitry A. Kazakov
  0 siblings, 2 replies; 11+ messages in thread
From: Puckdropper @ 2005-03-28 17:47 UTC (permalink / raw)


Thanks!  I got it to work properly using the with and use statements
that were added.

Is this question common enough to warrant adding to the Ada Programming
FAQ?  My Computer Science class had the same question (about the floats
and exponents) that was never answered.

Puckdropper
--
Google is proving to be very useful... Posting from there rather than
my ISP.




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

* Re: Exponent floats?
  2005-03-28 17:47       ` Puckdropper
@ 2005-03-28 18:34         ` Pascal Obry
  2005-03-28 22:27           ` Puckdropper
  2005-03-28 18:51         ` Dmitry A. Kazakov
  1 sibling, 1 reply; 11+ messages in thread
From: Pascal Obry @ 2005-03-28 18:34 UTC (permalink / raw)



"Puckdropper" <puckdropper@yahoo.com> writes:

> Is this question common enough to warrant adding to the Ada Programming
> FAQ?  My Computer Science class had the same question (about the floats
> and exponents) that was never answered.

Are you saying that the prof was not able to answer ?!?

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595



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

* Re: Exponent floats?
  2005-03-28 17:47       ` Puckdropper
  2005-03-28 18:34         ` Pascal Obry
@ 2005-03-28 18:51         ` Dmitry A. Kazakov
  2005-03-29  9:29           ` Martin Krischik
  1 sibling, 1 reply; 11+ messages in thread
From: Dmitry A. Kazakov @ 2005-03-28 18:51 UTC (permalink / raw)


On 28 Mar 2005 09:47:55 -0800, Puckdropper wrote:

> Thanks!  I got it to work properly using the with and use statements
> that were added.
> 
> Is this question common enough to warrant adding to the Ada Programming
> FAQ?  My Computer Science class had the same question (about the floats
> and exponents) that was never answered.

Well,

David Botton has:
http://www.adapower.com/faq/

Martin Krischik maintains Ada's wiki:
http://en.wikipedia.org/wiki/Ada_programming_language

There are many good introductory on-line books, like Ada distilled by
Richard Riehle:
http://www.adaic.org/docs/distilled/adadistilled.pdf
(I always give it to our students)

though to my knowledge nobody wrote something like that focused on numeric
issues. That would be very interesting, because people coming from other
languages usually have very little understanding of how advanced language
support for numerics could be. One should repeat over and over again what
fixed-point numbers are, what is the difference between ordinary and
decimal fixed-point types. Rounding and overflow issues for floating-point
types etc.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



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

* Re: Exponent floats?
  2005-03-28 18:34         ` Pascal Obry
@ 2005-03-28 22:27           ` Puckdropper
  0 siblings, 0 replies; 11+ messages in thread
From: Puckdropper @ 2005-03-28 22:27 UTC (permalink / raw)


Pascal Obry wrote:
> "Puckdropper" <puckdropper@yahoo.com> writes:
> 
> 
>>Is this question common enough to warrant adding to the Ada Programming
>>FAQ?  My Computer Science class had the same question (about the floats
>>and exponents) that was never answered.
> 
> 
> Are you saying that the prof was not able to answer ?!?
> 
> Pascal.
> 

Yeah.  He's only been using Ada as an introductory language for a few 
years, so he's far from a guru with it.  I'm trying to remember details 
of something that happened last year, but the book we were using had a 
listing of the specification of a few standard packages and apparently 
the floating point exponent was supposed to work.

Puckdropper
-- 
www.uncreativelabs.net

Old computers are getting to be a lost art. Here at Uncreative Labs, we 
still enjoy using the old computers. Sometimes we want to see how far a 
particular system can go, other times we use a stock system to remind 
ourselves of what we once had.

To email me directly, send a message to puckdropper (at) fastmail.fm



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

* Re: Exponent floats?
  2005-03-28 18:51         ` Dmitry A. Kazakov
@ 2005-03-29  9:29           ` Martin Krischik
  2005-03-29 18:55             ` Manuel G. R.
  0 siblings, 1 reply; 11+ messages in thread
From: Martin Krischik @ 2005-03-29  9:29 UTC (permalink / raw)


Dmitry A. Kazakov wrote:

>> Is this question common enough to warrant adding to the Ada Programming
>> FAQ?  My Computer Science class had the same question (about the floats
>> and exponents) that was never answered.
 
> Martin Krischik maintains Ada's wiki:
> http://en.wikipedia.org/wiki/Ada_programming_language

Of course you are welcome to add to the wiki everthing you have learned for

Martin 
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com




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

* Re: Exponent floats?
  2005-03-29  9:29           ` Martin Krischik
@ 2005-03-29 18:55             ` Manuel G. R.
  0 siblings, 0 replies; 11+ messages in thread
From: Manuel G. R. @ 2005-03-29 18:55 UTC (permalink / raw)


Martin Krischik wrote:
> Dmitry A. Kazakov wrote:
> 
>>Martin Krischik maintains Ada's wiki:
>>http://en.wikipedia.org/wiki/Ada_programming_language
> 
> 
> Of course you are welcome to add to the wiki everthing you have learned for
> 

Of course, but this link is to Wikipedia. The link to the wiki book is: 
http://en.wikibooks.org/wiki/Programming:Ada

-- 
Ada programming tutorial: http://en.wikibooks.org/wiki/Programming:Ada
Tutorial de programaci�n en Ada: 
http://es.wikibooks.org/wiki/Programaci%C3%B3n_en_Ada



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

end of thread, other threads:[~2005-03-29 18:55 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-28  4:49 Exponent floats? Puckdropper
2005-03-28  6:39 ` tmoran
2005-03-28  6:49 ` Dmitry A. Kazakov
2005-03-28  8:49   ` Pascal Obry
2005-03-28  9:57     ` Dmitry A. Kazakov
2005-03-28 17:47       ` Puckdropper
2005-03-28 18:34         ` Pascal Obry
2005-03-28 22:27           ` Puckdropper
2005-03-28 18:51         ` Dmitry A. Kazakov
2005-03-29  9:29           ` Martin Krischik
2005-03-29 18:55             ` Manuel G. R.

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