Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

converting

sweetfaith2001sweetfaith2001 Posts: 10Member
Hi,
I have been working and getting along pretty well in pascal but i just encountered 2 problems that i couldn't do. I searched for some points in the book and on the net but i can't find the ones I want.

I would like to
- convert a string into an Integer;
- convert a string to real (which i know is similar to the above one)but specifying number of decimal points.

N.B I know how to convert a real number to string, will that help?


Thank you

Sweetfaith

Comments

  • zibadianzibadian Posts: 6,349Member
    : Hi,
    : I have been working and getting along pretty well in pascal but i just encountered 2 problems that i couldn't do. I searched for some points in the book and on the net but i can't find the ones I want.
    :
    : I would like to
    : - convert a string into an Integer;
    : - convert a string to real (which i know is similar to the above one)but specifying number of decimal points.
    :
    : N.B I know how to convert a real number to string, will that help?
    :
    :
    : Thank you
    :
    : Sweetfaith
    :
    For both problems, you'll need to use the Val() function. You cannot specify the number of decimals when converting strings into reals, other than type-casting the real as one of the real-types (i.e. single, real, double, extended). Pascal will automatically append decimal 0's to the number or remove everal decimal.
Sign In or Register to comment.