krydea
asked on
verry verry easy how can you : a integer i thought it was /
hello,
domn question but i never : a integer so i don't konw hot to do it i thought that it was a / like integer:=interger/integer;
Krydea
sorry to ask it realy lame question..
domn question but i never : a integer so i don't konw hot to do it i thought that it was a / like integer:=interger/integer;
Krydea
sorry to ask it realy lame question..
ASKER
10:2=5 that how can i do that in delphi?
10 div 2 = 5
VAR X : single;
a,b,c : Integer;
begin
a := 10; b := 3;
x := a/b;
c := a DIV b;
end;
a,b,c : Integer;
begin
a := 10; b := 3;
x := a/b;
c := a DIV b;
end;
ASKER
what is a single?
var
x : Variant;
a,b,c : Integer;
begin
a := 10;
b := 3;
x := int(a/b);
c := integer(x);
end;
x : Variant;
a,b,c : Integer;
begin
a := 10;
b := 3;
x := int(a/b);
c := integer(x);
end;
ASKER
oke but if i whant to get 3.3333333333333333333 or 2.3653636 something presize?
10 / 3 = 3.33333333333333333333333
10 div 3 = 3
10 div 3 = 3
ASKER
yea and i and how can i do that 3.33333 and case i use inttostr and i have to use then?
If you use an Integer, you cannot expect 3.3333333 or something like that.
Try to use a "REAL":
var
a,b,c: real;
begin
a := 10;
b := 3;
c := a / b;
end;
Here, b will get 3.33333 as its value.
Good luck!
Roosiedb
Try to use a "REAL":
var
a,b,c: real;
begin
a := 10;
b := 3;
c := a / b;
end;
Here, b will get 3.33333 as its value.
Good luck!
Roosiedb
You can use the Val procedure or Format function to convert from real to string.
ASKER
roosiedb : how does the val funcion works?:[
scrapdog over and out =)
ASKER
oke this is bad
i will tel exacly what i whant to do..
furst i get F=Q/Z then i get X=X*F Y=Y*F so furst i have to calculate the Factor F of Q/Z and that can be a 3.333 but Q/Z are bouth integer X and Y to so i'm in serius troubel..
is this posible?
i will tel exacly what i whant to do..
furst i get F=Q/Z then i get X=X*F Y=Y*F so furst i have to calculate the Factor F of Q/Z and that can be a 3.333 but Q/Z are bouth integer X and Y to so i'm in serius troubel..
is this posible?
Declare the variables this way:
var
f :real;
x, y, q ,z :integer;
and perform the computation this way:
f := q / z;
x := round(x * f);
y := round(y * f);
var
f :real;
x, y, q ,z :integer;
and perform the computation this way:
f := q / z;
x := round(x * f);
y := round(y * f);
ASKER
k, i'm trying this stuff but can you plz explane what round does case i whant to laern and not be a scriptkid:p
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
cool tanx
ASKER
i'm going to sleep now i will inserd it to my programme and give you the points then:)
a := b div c;