Delphi newbie: Integer to extended typecast 
Author Message
 Delphi newbie: Integer to extended typecast

I want to put an integer value into this:

var MyValue: longint;
begin
   label1.caption:='Count:'+
   format('%10.5f',[MyValue])
end;

However, this gives a run-time error, because format expects a
floating point value.

Well, can we take an integer and "make" it floating point, after all,
100 equals 100.00.

I have had quite a bit of success using TDateTime and Extended, and
changing Extended to Integer using

   MyInteger:=Trunc(MyExtended) or
   MyInteger:=Trunc(TDateTime)

How about changing from integers to Extended? Compiler says "invalid
typecast" on this:

var MyInteger: integer;
  NewExtended: extended;
begin
    NewExtended:= Extended(MyInteger);
    NewExtended:= (MyInteger as Extended);
end;

Who has any clues?

Email appreciated, I respond to every email.
Matthew



Wed, 01 Sep 1999 03:00:00 GMT  
 Delphi newbie: Integer to extended typecast

Quote:

> I want to put an integer value into this:

> var MyValue: longint;
> begin
>    label1.caption:='Count:'+
>    format('%10.5f',[MyValue])
> end;

> However, this gives a run-time error, because format expects a
> floating point value.

Format expects a float because your format string says so! Use 'd'
instead of 'f' and it should work :-))

Jasper



Thu, 02 Sep 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Typecast SET to INTEGER ?

2. Q: How do you typecast an integer to an extended variable?

3. (newbie) textbook featuring extended pascal and object pascal

4. newbie and integers

5. storing a list of integers in one integer.

6. Extended Store Procedure using Delphi & MSSQL

7. Delphi: .db's and extended ascii

8. Invalid Class Typecast

9. SQL-Typecasting to boolean ?

10. value typecasts

11. A question about typecasting

12. typecasting preferences

 

 
Powered by phpBB® Forum Software