Re: HPGCC related ...
- From: Claudio Lapilli <pleasedontspam@xxxxxxx>
- Date: Wed, 19 Mar 2008 09:35:32 -0700 (PDT)
On Mar 19, 6:23 am, ilko...@xxxxxxxxx wrote:
On Mar 4, 4:07 pm, Wes <wjltemp...@xxxxxxxxx> wrote:
On Mar 3, 8:55 pm, ilko...@xxxxxxxxx wrote:
I am getting more curious!?
I really would like to know which version of the HPGCC compiler you
are using and the header file.
HPGCC_VERSION: 2.0
HPGCC_REVISION: 563
The entire file is:
-----------------------------------
#include <hpgcc49.h>
int main()
{
float f;
double d;
clear_screen(); //clear the screen
scanf("%f",&f); // should work but doesn't
scanf("%lf",&d); // works as expected
scanf("%f",&d); // should fail but doesn't
printf("%f, %f, %f\n",f,d,d);
WAIT_CANCEL;
return 0;}
-----------------------------------
In any case, I would highly recommend using sat_pop_real(),
sat_push_real().
The HPStack library has: hps_pop_real(), hps_push_real(),
hps_pick_real().
I really wonder if there is a more
simple command to implement on HPGCC than scanf or printf?
Hmmm. I would have thought that these functions would be two of the
largest functions to implement.
-wes
I have tried your code and none of my enteries could be printed on the
screen. I really want to know what is different with your way of doing
it and mine.
Besides, your suggestion about using the stack library. It is working,
but you can realize that it is working when you QUIT the program. That
is, you see all your displayed data in stack. As you can surely
understand without my saying that, after calling CLEAR_SCREEN() you
lost all your visual contact with the STACK? Am I wrong? There is no
use to print values to stack after calling the CLEAR_SCREEN()
function.
I am currently entering my variables as strings. Then I use the atof()
function. This is working as far as input is concerned. I am still
having problems to display floats or doubles on screen. I have used
sprintf() fuction and it is not working properly. It behaves just like
printf() function. All I can have is some numbers which I couldn't be
able to give any meaning to them. My plan was to convert the float or
double into string and print the converted string on screen. In worst
case I will code a small function to convert floats or doubles into
strings. If I have the enough amount of memory, though.
/Onur- Hide quoted text -
- Show quoted text -
First of all, there are no known problems displaying floating point
numbers on the screen, so the problem is in your code. Second, you
probably don't deserve my help due to your arrogance in posts above,
but here it is anyway...
To print a double:
double mydouble;
printf("%lf",mydouble);
to print a float:
float myfloat;
printf("%lf",(double)myfloat);
to read a number from the console:
double mydouble;
scanf("%lf",&mydouble);
and if you want to read it as float:
double temp;
float myfloat;
scanf("%lf",&temp);
myfloat=temp;
The forced conversion to double is required because we dropped support
for low-precision floats in HPGCC, in favor of higher-precision
doubles and even higher decNumbers.
When you use variable-argument functions, it is your responsibility to
provide proper argument type conversion.
All math functions use doubles internally, so using float will only
add unnecessary overhead to your calculations, though saving storage
space.
Regards,
Claudio
.
- References:
- HPGCC related ...
- From: ilkorur
- Re: HPGCC related ...
- From: Wes
- Re: HPGCC related ...
- From: ilkorur
- Re: HPGCC related ...
- From: Wes
- Re: HPGCC related ...
- From: ilkorur
- HPGCC related ...
- Prev by Date: In 50g, how to change laplace vx to s or t
- Next by Date: Re: HPGCC related ...
- Previous by thread: Re: HPGCC related ...
- Next by thread: Re: HPGCC related ...
- Index(es):
Relevant Pages
|
|