Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-other / 2001-11

How can I change the variable value?

5 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Du xiaobo

When I tried to perform the function of dividing one INTEGER:20 by another INTEGER:10, I always got the statment that the result is in REAL type instead of INTEGER as expected. what happened and How can I change the setting?
Thanks in advance!

Reply by email

Jonas Maebe
to Du xiaobo
Du xiaobo wrote
When I tried to perform the function of dividing one INTEGER:20 by another INTEGER:10, I always got the statment that the result is in REAL type instead of INTEGER as expected. what happened and How can I change the setting?

Use "div" instead of "/", that will give you an integer result.

Jonas

Reply by email

Noah silva
to Du xiaobo: When I tried to perform the function of dividing one INTEGER:20 by another INTEGER:10, I…

you have to use DIV instead of a /.

Think about it:

for example: 15 / 2 isn't an integer, even though 15 and 2 are both integers.

Du xiaobo wrote 11 lines
When I tried to perform the function of dividing one INTEGER:20 by another INTEGER:10, I always got the statment that the result is in REAL type instead of INTEGER as expected. what happened and How can I change the setting? Thanks in advance! _______________________________________________ fpc-other maillist - http://lists.freepascal.org/mailman/listinfo/fpc-other

Reply by email

Michael Wodrich
to Noah silva

von: Michael Wodrich
verfasst: 17.11.2001 20:51:57 (GMT+02.00)

Dividing two numbers results in a REAL number.
For this reason you MUST take DIV to get an INTEGER.

hth
Michael Wodrich

Noah silva schrieb am 16.11.2001:

Show quoted text 14 lines
Think about it: for example: 15 / 2 isn't an integer, even though 15 and 2 are both integers. On Fri, 16 Nov 2001, Du xiaobo wrote: > When I tried to perform the function of dividing one INTEGER:20 by > another INTEGER:10, I always got the statment that the result is in REAL > type instead of INTEGER as expected. what happened and How can I change > the setting? > Thanks in advance!
Programmieren, dass spannendste Detektivspiel der Welt.

Reply by email