SRL Archive - OSR Help

Decimals


Death12652

2010-05-16 15:09:40

How to you get scar to convert an integer into a decimal. like if X := 50. How do you make X := 0.05

Frement

2010-05-16 15:13:47

program New;

var I: Integer;
E: Extended;

begin
I := 50;
E := StrToFloat(IntToStr(I));
end.

i luffs yeww

2010-05-16 15:16:11


var
x: Extended;
i: Integer;

begin
i := 5;
x := i + 0.0;
Writeln('x: '+ToStr(x));
end.

Hope that helps.

Frement! Bad practice to do some many conversions. :<

And you never use S.

Frement

2010-05-16 15:18:29

From: i luffs yeww

var
x: Extended;
i: Integer;

begin
i := 5;
x := i + 0.0;
Writeln('x: '+ToStr(x));
end.

Hope that helps.

Frement! Bad practice to do some many conversions. :<

And you never use S.


I just couldnt think of any easier way then :) But after reading your post i felt stupid, anyway, i fixed the S before you edited, and GET ON MSN!!!

Death12652

2010-05-16 15:22:41

Those Both Don't work? Well Frements works but it only displays 50.

i luffs yeww

2010-05-16 15:27:13

You have to run mine on Simba. :p Sorry.

Basically, you just need to add 0.0 to an integer to make it extended.

Frement

2010-05-16 15:27:22

From: death12652
Those Both Don't work? Well Frements works but it only displays 50.


program New;

var I: Integer;
E: Extended;

begin
I := 50;
E := StrToFloat(IntToStr(I));
E := E + 5.5;
Writeln(E);
end.

Yes it does?

i luffs yeww

2010-05-16 15:36:29

Also, for your specific example..


var
ext: Extended;
int: Integer;

begin
int := 50;
ext := int * 0.001;
Writeln(ext);
end.


Successfully compiled (102 ms)
0.05
Successfully executed