SRL Archive - RS3 Help

Do the math


SlipperyPickle

2015-01-25 09:22:45

Hi,

I guess it's a noob question, but for my script I try to calculate the profit. But I get an error. I guess that's because it isn't a round number (don't know the exact English word) but it's a number like "31.3323". How do I calculate in Simba with comma numbers.

This is my code:

procedure procedure();
var
a, b, c: integer;

begin
a := grandExchange.getPrice(6983);
b := (grandExchange.getPrice(6979) * 10);
c := (b - a) / 3;
writeLn(IntToStr(c));
end;

this is the erorr, which points to "c := (b - a) / 3;":
Error: Can't assign "Extended" to "Int32" at line ..

Thanks in advance!

Kyle

2015-01-25 09:26:41

Change "a, b, c" to be Extended and not Integer.

SlipperyPickle

2015-01-25 09:34:32

From: elfyyy
Change "a, b, c" to be Extended and not Integer.


Thanks, that did the trick! :)

masterBB

2015-01-25 09:49:14

Actually, you should make just c of the type Extended. Integer is big enough for a and b, because they are never floating numbers, at least that is what I assume.

SlipperyPickle

2015-01-25 10:06:33

From: masterBB
Actually, you should make just c of the type Extended. Integer is big enough for a and b, because they are never floating numbers, at least that is what I assume.


I did that, here is my code.

procedure progressReport();
var
a, b, d: integer;
c: Extended;

begin
a := grandExchange.getPrice(6983);
b := (grandExchange.getPrice(6979) * 10);
c := (b - a) / 3;
d := Round(c);
end;

The Mayor

2015-01-25 14:47:21

From: Suikerwafel
I did that, here is my code.

procedure progressReport();
var
a, b, d: integer;
c: Extended;

begin
a := grandExchange.getPrice(6983);
b := (grandExchange.getPrice(6979) * 10);
c := (b - a) / 3;
d := Round(c);
end;


Can you put it on 1 line :D

SlipperyPickle

2015-01-25 14:54:49

From: The Mayor
Can you put it on 1 line :D


procedure procedure();
begin
writeln(IntToStr(Round(((grandExchange.getPrice(6979) * 10) - (grandExchange.getPrice(6983))) / 3)));
end;

Good enough?

The Mayor

2015-01-25 15:12:53

From: Suikerwafel
procedure procedure();
begin
writeln(IntToStr(Round(((grandExchange.getPrice(6979) * 10) - (grandExchange.getPrice(6983))) / 3)));
end;

Good enough?


Very nice :)