comp.lang.ada
 help / color / mirror / Atom feed
* i need help w/problem
@ 1999-02-21  0:00 zufandel
  1999-02-22  0:00 ` Allan Davis
  0 siblings, 1 reply; 16+ messages in thread
From: zufandel @ 1999-02-21  0:00 UTC (permalink / raw)


I am at wits end...I am taking ada class..and we have a small project and I
dont understand one feature that i am supposed to do...I would appreciate
any help from anyone.

We have to input a float number and then print the 2 sides of the decimal by
themselves...for example...999.88 the output has to be

999          88

without the decimal point..I have racked my brains out trying to figure this
out..could anyone please help me with this?

TIA

Zuf







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

* Re: i need help w/problem
  1999-02-22  0:00         ` Mike Silva
@ 1999-02-22  0:00           ` Nick Roberts
  1999-02-22  0:00           ` dennison
  1999-02-22  0:00           ` zufandel
  2 siblings, 0 replies; 16+ messages in thread
From: Nick Roberts @ 1999-02-22  0:00 UTC (permalink / raw)


Okay, a hint (to the NG). Try looking up the Floor attribute.

-------------------------------------
Nick Roberts
-------------------------------------








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

* Re: i need help w/problem
  1999-02-21  0:00 i need help w/problem zufandel
@ 1999-02-22  0:00 ` Allan Davis
  1999-02-22  0:00   ` bill
  1999-02-22  0:00   ` Corey Ashford
  0 siblings, 2 replies; 16+ messages in thread
From: Allan Davis @ 1999-02-22  0:00 UTC (permalink / raw)


you convert the float number to string and then slice in

ie.    -- variables
        num1 : float :=999.88;
        number : string(1.. 6);
        counter : natural :=1;
        --body
         number := string(num1);
         while ( number(counter) \= '.' and counter \= number'last) loop
                counter := counter +1;
        end loop
        if (counter \= number'last) then
               put(number(1..counter-1) +" "+ number(counter+1..
number'last);
        end if




zufandel wrote in message <7aqjie$npj@netaxs.com>...
>I am at wits end...I am taking ada class..and we have a small project and I
>dont understand one feature that i am supposed to do...I would appreciate
>any help from anyone.
>
>We have to input a float number and then print the 2 sides of the decimal
by
>themselves...for example...999.88 the output has to be
>
>999          88
>
>without the decimal point..I have racked my brains out trying to figure
this
>out..could anyone please help me with this?
>
>TIA
>
>Zuf
>
>
>






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

* Re: i need help w/problem
  1999-02-22  0:00 ` Allan Davis
  1999-02-22  0:00   ` bill
@ 1999-02-22  0:00   ` Corey Ashford
  1999-02-22  0:00     ` David C. Hoos, Sr.
  1999-02-22  0:00     ` robert_dewar
  1 sibling, 2 replies; 16+ messages in thread
From: Corey Ashford @ 1999-02-22  0:00 UTC (permalink / raw)


Allan Davis wrote:
> 
> you convert the float number to string and then slice in
> 
> ie.    -- variables
>         num1 : float :=999.88;
>         number : string(1.. 6);
>         counter : natural :=1;
>         --body
>          number := string(num1);

That conversion won't work.

Use something like:

          number : constant string := float'image(float_variable);

in this case, float_variable = 999.98.

[rest of post snipped due to picky newgroup server]

- Corey




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

* Re: i need help w/problem
  1999-02-22  0:00 ` Allan Davis
@ 1999-02-22  0:00   ` bill
  1999-02-22  0:00   ` Corey Ashford
  1 sibling, 0 replies; 16+ messages in thread
From: bill @ 1999-02-22  0:00 UTC (permalink / raw)


In article <Iz6A2.2502$LN5.3278079@news2.mia>, "Allan says...
>

>you convert the float number to string and then slice in
>
>        num1 : float :=999.88;
>        number : string(1.. 6);
>        counter : natural :=1;
>        --body
>         number := string(num1);

As Corey said, you cant do this! (this is not C :)

>         while ( number(counter) \= '.' and counter \= number'last) loop
>                counter := counter +1;
>        end loop

To find a pattern within a string, you might want to use some of the
search subprograms for type string such as Index(..), which will find for
you the index that some pattern is located within a string.
Index(..) is part of the standard Ada library.

Bill.
 




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

* Re: i need help w/problem
  1999-02-22  0:00   ` Corey Ashford
  1999-02-22  0:00     ` David C. Hoos, Sr.
@ 1999-02-22  0:00     ` robert_dewar
  1999-02-22  0:00       ` dennison
  1999-02-22  0:00       ` Matthew Heaney
  1 sibling, 2 replies; 16+ messages in thread
From: robert_dewar @ 1999-02-22  0:00 UTC (permalink / raw)


In article <36D0FD58.6474E351@rocketmail.com>,
  Corey Ashford <yeroca@rocketmail.com> wrote:
> Allan Davis wrote:

It seems appropriate to remind people that when a student
asks on this group for help doing an assignment, it is NOT
helpful to solve the assignment. On the contrary, this is
very unfair to the student, since it means that the whole
point of the assignment is lost, which is not to hand in
something that works, but rather FIGURE OUT how to to hand
in something that works.

A hint to set thinking in the right direction is certainly
appropriate, but it is never appropriate to post exact
code (whether right or wrong :-)

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

* Re: i need help w/problem
  1999-02-22  0:00   ` Corey Ashford
@ 1999-02-22  0:00     ` David C. Hoos, Sr.
  1999-02-22  0:00       ` Matthew Heaney
  1999-02-22  0:00     ` robert_dewar
  1 sibling, 1 reply; 16+ messages in thread
From: David C. Hoos, Sr. @ 1999-02-22  0:00 UTC (permalink / raw)



Corey Ashford wrote in message <36D0FD58.6474E351@rocketmail.com>...
<snip>
>That conversion won't work.
>
>Use something like:
>
>          number : constant string := float'image(float_variable);
>
>in this case, float_variable = 999.98.
>
>[rest of post snipped due to picky newgroup server]


Well, this conversion won't work either, because the 'image attribute uses
exponential notation -- see RM95 3.5(33).

It's probably better to use an instantiation of Text_IO.Float_IO.Put, with
appropriate Fore, Aft, and Exp values to write the string.  This will have
the further advantage that it will not be necessary to search for the
decimal point, because its position will have been specified by means of the
parameters.

Of course, there will be trailing zeroes on the fractional part which may
need to be dropped, so a search will be needed there.







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

* Re: i need help w/problem
  1999-02-22  0:00     ` robert_dewar
@ 1999-02-22  0:00       ` dennison
  1999-02-22  0:00         ` zufandel
  1999-02-22  0:00       ` Matthew Heaney
  1 sibling, 1 reply; 16+ messages in thread
From: dennison @ 1999-02-22  0:00 UTC (permalink / raw)


In article <7arnh3$av$1@nnrp1.dejanews.com>,
  robert_dewar@my-dejanews.com wrote:
> In article <36D0FD58.6474E351@rocketmail.com>,
>   Corey Ashford <yeroca@rocketmail.com> wrote:
> > Allan Davis wrote:
>
> It seems appropriate to remind people that when a student
> asks on this group for help doing an assignment, it is NOT
> helpful to solve the assignment. On the contrary, this is

> A hint to set thinking in the right direction is certainly
> appropriate, but it is never appropriate to post exact
> code (whether right or wrong :-)

Also, the "right direction" is often the direction of the office of the
student's instructor.

T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

* Re: i need help w/problem
  1999-02-22  0:00     ` David C. Hoos, Sr.
@ 1999-02-22  0:00       ` Matthew Heaney
  1999-02-23  0:00         ` Pascal Obry
  0 siblings, 1 reply; 16+ messages in thread
From: Matthew Heaney @ 1999-02-22  0:00 UTC (permalink / raw)


"David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> writes:

> It's probably better to use an instantiation of Text_IO.Float_IO.Put...

Since subtype Float was being used, a better choice may be the
predefined package Ada.Float_Text_IO, which was specifically intended to
remove the entry barrier for neophyte Ada programmers.

A very subtle point: Float_Text_IO is _not_ an instantiation of
Text_IO.Float_IO.  It takes Float parameters, and looks just like an
instantiation of Float_IO, but it is not actually an instantiation of
Float_IO.

Which mostly means if you have this:

generic
  type Float_Type is digits <>;
  with package P is new Ada.Text_IO.Float_IO (Float_Type);
package GQ is ...

then the following instantiation

package Q is new GQ (Float, Float_Text_IO);

is illegal.













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

* Re: i need help w/problem
  1999-02-22  0:00     ` robert_dewar
  1999-02-22  0:00       ` dennison
@ 1999-02-22  0:00       ` Matthew Heaney
  1999-02-22  0:00         ` Mike Silva
  1 sibling, 1 reply; 16+ messages in thread
From: Matthew Heaney @ 1999-02-22  0:00 UTC (permalink / raw)


robert_dewar@my-dejanews.com writes:

> It seems appropriate to remind people that when a student
> asks on this group for help doing an assignment, it is NOT
> helpful to solve the assignment.

The other thing is that if you do give a hint, send the hint directly,
via a private email to the student.  Don't post the hints on CLA.








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

* Re: i need help w/problem
  1999-02-22  0:00       ` Matthew Heaney
@ 1999-02-22  0:00         ` Mike Silva
  1999-02-22  0:00           ` Nick Roberts
                             ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Mike Silva @ 1999-02-22  0:00 UTC (permalink / raw)



Matthew Heaney wrote in message ...
<...>
>The other thing is that if you do give a hint, send the hint directly,
>via a private email to the student.  Don't post the hints on CLA.


I don't agree with this.  I learned something from the multiple answers /
hints posted, even though I wasn't the one who asked the question.  They
will also now be available via dejanews to others in the future.  Especially
given the low volume of this newsgroup I look forward to reading and
learning whatever I can here.

Mike







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

* Re: i need help w/problem
  1999-02-22  0:00       ` dennison
@ 1999-02-22  0:00         ` zufandel
  0 siblings, 0 replies; 16+ messages in thread
From: zufandel @ 1999-02-22  0:00 UTC (permalink / raw)




To all the people who posted (except allen davis) ..thanks a lot..your posts
were very informative and helped however, some of them were over my head
since this is my 5th week in the Ada course:)  However it was refreshing to
see that many people were ready to come and help me with this problem..again
thanks to you!  Keep up the good work!!

Cheers
~Z
dennison@telepath.com wrote in message <7arrsl$45k$1@nnrp1.dejanews.com>...
>In article <7arnh3$av$1@nnrp1.dejanews.com>,
>  robert_dewar@my-dejanews.com wrote:
>> In article <36D0FD58.6474E351@rocketmail.com>,
>>   Corey Ashford <yeroca@rocketmail.com> wrote:
>> > Allan Davis wrote:
>>
>> It seems appropriate to remind people that when a student
>> asks on this group for help doing an assignment, it is NOT
>> helpful to solve the assignment. On the contrary, this is
>
>> A hint to set thinking in the right direction is certainly
>> appropriate, but it is never appropriate to post exact
>> code (whether right or wrong :-)
>
>Also, the "right direction" is often the direction of the office of the
>student's instructor.
>
>T.E.D.
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own






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

* Re: i need help w/problem
  1999-02-22  0:00         ` Mike Silva
  1999-02-22  0:00           ` Nick Roberts
  1999-02-22  0:00           ` dennison
@ 1999-02-22  0:00           ` zufandel
  2 siblings, 0 replies; 16+ messages in thread
From: zufandel @ 1999-02-22  0:00 UTC (permalink / raw)


good pt mike which obviously went over the heads of a few here..LOL...

cheers
~Z

-- you can take a horse to water but you cant make him drink

Mike Silva wrote in message <7as9ri$ed9$1@its.hooked.net>...
>
>Matthew Heaney wrote in message ...
><...>
>>The other thing is that if you do give a hint, send the hint directly,
>>via a private email to the student.  Don't post the hints on CLA.
>
>
>I don't agree with this.  I learned something from the multiple answers /
>hints posted, even though I wasn't the one who asked the question.  They
>will also now be available via dejanews to others in the future.
Especially
>given the low volume of this newsgroup I look forward to reading and
>learning whatever I can here.
>
>Mike
>
>
>






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

* Re: i need help w/problem
  1999-02-22  0:00         ` Mike Silva
  1999-02-22  0:00           ` Nick Roberts
@ 1999-02-22  0:00           ` dennison
  1999-02-22  0:00           ` zufandel
  2 siblings, 0 replies; 16+ messages in thread
From: dennison @ 1999-02-22  0:00 UTC (permalink / raw)


In article <7as9ri$ed9$1@its.hooked.net>,
  "Mike Silva" <mjsilva@jps.net> wrote:
>
> Matthew Heaney wrote in message ...
> <...>
> >The other thing is that if you do give a hint, send the hint directly,
> >via a private email to the student.  Don't post the hints on CLA.
>
> I don't agree with this.  I learned something from the multiple answers /
> hints posted, even though I wasn't the one who asked the question.  They
> will also now be available via dejanews to others in the future.  Especially
> given the low volume of this newsgroup I look forward to reading and
> learning whatever I can here.

Also, if part of my "hint" turns out to be wrong, there is likely to be a
rather prompt correction from the group at large. That can be a bit bruising
to my ego, but much more helpful for the original poster.

T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




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

* Re: i need help w/problem
  1999-02-22  0:00       ` Matthew Heaney
@ 1999-02-23  0:00         ` Pascal Obry
  1999-02-23  0:00           ` Matthew Heaney
  0 siblings, 1 reply; 16+ messages in thread
From: Pascal Obry @ 1999-02-23  0:00 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1640 bytes --]

Matthew Heaney a �crit dans le message ...
>"David C. Hoos, Sr." <david.c.hoos.sr@ada95.com> writes:
>
>> It's probably better to use an instantiation of Text_IO.Float_IO.Put...
>
>Since subtype Float was being used, a better choice may be the
>predefined package Ada.Float_Text_IO, which was specifically intended to
>remove the entry barrier for neophyte Ada programmers.
>
>A very subtle point: Float_Text_IO is _not_ an instantiation of
>Text_IO.Float_IO.  It takes Float parameters, and looks just like an
>instantiation of Float_IO, but it is not actually an instantiation of
>Float_IO.
>

This is not my reading of the reference manual. In A.10.9 we can read :

-----------------------------------------------------------
(32)
Float_Text_IO is a library package that is a nongeneric equivalent to
Text_IO.Float_IO for the predefined type Float:

(33)
       with Ada.Text_IO;
       package Ada.Float_Text_IO is new Ada.Text_IO.Float_IO(Float);

(34)
For each predefined floating point type, a nongeneric equivalent to
Text_IO.Float_IO is provided, with names such as Ada.Long_Float_Text_IO.
Implementation Permissions

(37)
The nongeneric equivalent packages may, but need not, be actual
instantiations of the generic package for the appropriate predefined type.
-----------------------------------------------------------

The point (37) say that it may be actual instantiations of the generic
package. So your point is
fine for full compatibility with all Ada compiler but you can't say that
Float_Text_IO is not an
instantiation of Ada.Text_IO.Float_IO. In fact I'am pretty sure that most
compilers will do that.

Pascal.






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

* Re: i need help w/problem
  1999-02-23  0:00         ` Pascal Obry
@ 1999-02-23  0:00           ` Matthew Heaney
  0 siblings, 0 replies; 16+ messages in thread
From: Matthew Heaney @ 1999-02-23  0:00 UTC (permalink / raw)


"Pascal Obry" <p.obry@der.edf.fr> writes:

> (37)
> The nongeneric equivalent packages may, but need not, be actual
> instantiations of the generic package for the appropriate predefined type.
> -----------------------------------------------------------
> 
> The point (37) say that it may be actual instantiations of the generic
> package. So your point is
> fine for full compatibility with all Ada compiler but you can't say that
> Float_Text_IO is not an
> instantiation of Ada.Text_IO.Float_IO. In fact I'am pretty sure that most
> compilers will do that.


I stand corrected.  Thanks for pointing that out to me.

Matt




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

end of thread, other threads:[~1999-02-23  0:00 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-21  0:00 i need help w/problem zufandel
1999-02-22  0:00 ` Allan Davis
1999-02-22  0:00   ` bill
1999-02-22  0:00   ` Corey Ashford
1999-02-22  0:00     ` David C. Hoos, Sr.
1999-02-22  0:00       ` Matthew Heaney
1999-02-23  0:00         ` Pascal Obry
1999-02-23  0:00           ` Matthew Heaney
1999-02-22  0:00     ` robert_dewar
1999-02-22  0:00       ` dennison
1999-02-22  0:00         ` zufandel
1999-02-22  0:00       ` Matthew Heaney
1999-02-22  0:00         ` Mike Silva
1999-02-22  0:00           ` Nick Roberts
1999-02-22  0:00           ` dennison
1999-02-22  0:00           ` zufandel

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