Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

verry verry easy how can you : a integer i thought it was /

Posted on 2001-08-14
19
Medium Priority
?
174 Views
Last Modified: 2010-04-06
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..
0
Comment
Question by:krydea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
19 Comments
 
LVL 5

Expert Comment

by:scrapdog
ID: 6386323
do you mean dividing integers?

a := b div c;
0
 

Author Comment

by:krydea
ID: 6386359
10:2=5 that how can i do that in delphi?
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 6386389
10 div 2 = 5
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:sesa
ID: 6386617
VAR X : single;
    a,b,c : Integer;
begin
  a := 10; b := 3;
  x := a/b;
  c := a DIV b;
end;
0
 

Author Comment

by:krydea
ID: 6387405
what is a single?
0
 
LVL 3

Expert Comment

by:oraelbis
ID: 6387486
var
   x : Variant;
   a,b,c : Integer;
begin
 a := 10;
 b := 3;
 x := int(a/b);
 c := integer(x);
end;
0
 

Author Comment

by:krydea
ID: 6387722
oke but if i whant to get 3.3333333333333333333 or 2.3653636 something presize?
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 6388080
10 / 3 = 3.33333333333333333333333
10 div 3 = 3
0
 

Author Comment

by:krydea
ID: 6388101
yea and i and how can i do that 3.33333 and case i use inttostr and i have to use then?
0
 

Expert Comment

by:roosiedb
ID: 6388389
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
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 6388422
You can use the Val procedure or Format function to convert from real to string.
0
 

Author Comment

by:krydea
ID: 6388491
roosiedb : how does the val funcion works?:[
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 6388507
scrapdog over and out =)
0
 

Author Comment

by:krydea
ID: 6389496
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?
0
 
LVL 5

Expert Comment

by:scrapdog
ID: 6389519
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);
0
 

Author Comment

by:krydea
ID: 6389535
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
0
 
LVL 5

Accepted Solution

by:
scrapdog earned 40 total points
ID: 6389553
"round" is a function that accepts an expression of type "real", and returns the result (as an integer) rounded to the nearest whole number
0
 

Author Comment

by:krydea
ID: 6389577
cool tanx
0
 

Author Comment

by:krydea
ID: 6389579
i'm going to sleep now i will inserd it to my programme and give you the points then:)
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question