This should be quick,
Q. How do I make 3400 into 3.4? When I say;
SCAR Code:procedure ConvertThatSOB;
var
Number : longint;
begin
Number := 3400 / 1000;
Writeln(FloatToStr(Number));
end;
..the answer comes out as "3".
This should be quick,
Q. How do I make 3400 into 3.4? When I say;
SCAR Code:procedure ConvertThatSOB;
var
Number : longint;
begin
Number := 3400 / 1000;
Writeln(FloatToStr(Number));
end;
..the answer comes out as "3".
Project: Welcome To Rainbow
Shouldnt it be an Extend?
And
Writeln(inttostr(Number));
Originally Posted by irc
Ill try it
SCAR Code:3
Successfully executed
Nope Didnt work
Project: Welcome To Rainbow
SCAR Code:procedure ConvertThatSOB;
var
Number : Extended;
begin
Number := 3400.0 div 1000.0;
Writeln(FloatToStr(Number));
end;
Eureeka!
Try it! The numbers need decimal points.
Originally Posted by irc
SCAR Code:program New;
begin
WriteLn(FloatToStr(3400.0 / 1000.0));
end.
Like that?Successfully compiled (367 ms)
3.4
Successfully executed
EDIT: noidea has the right idea (go figure!).
:-)
Method, yours it prolly faster![]()
Originally Posted by irc
Thanks Method and noidea! Ok, one more problem....
How do i make "3400" to "3400.0" through scripting??
Note: 3400 will always be a whole number
Project: Welcome To Rainbow
3400.0 is a whole number
Originally Posted by irc
Cool! Mines faster!
Originally Posted by irc
i mean that "3400" will be changing
so it will be
SCAR Code:if(JugsCollected >= 1000)then
begin
JugsCollected := JugsCollected / 1000;
JugsFinal := FloatToStr(JugsCollected)+'K';
end;
and JugsCollected will always be a whole number, so how do i add the ".0" on the end so that the function works?
Project: Welcome To Rainbow
There is no .0 on the end. Just change its type to Extended, and if there's a decimal involved, you'll get one.
:-)
SCAR Code:program New;
var
JugsCollected: Extended;
JugsFinal: String;
begin
JugsCollected := 1000;
if(JugsCollected >= 1000)then
begin
JugsCollected := JugsCollected / 1000;
JugsFinal := FloatToStr(JugsCollected + 0.0)+'K';
Writeln((JugsFinal));
end;
end.
Run that. Is it what your looking for?
Nvm, Method got it this time![]()
Originally Posted by irc
sweet, thanks guys
Project: Welcome To Rainbow
There are currently 1 users browsing this thread. (0 members and 1 guests)