Transform a type of variable that is Currency into Type Integer

Posted on 2003-03-20
Medium Priority
Last Modified: 2010-04-04
I have to variables

X : Currency;     X that is currency.
Y : Integer;      Y tha is Integer.

when i put ( Y := X ) i get "Imcompatible types: "Currency" and "Integer".
how do i make the Currency to Integer. Please somone Help
Question by:Fredy992
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

Expert Comment

ID: 8173065
You can use this code and your code will be corrected:


But it's not safety. You can use direct convert methods that defined in sysutils.

Expert Comment

ID: 8173100
A fine solution (and save) is

y := trunc(x);

this always works :)
LVL 27

Expert Comment

ID: 8173122
or also

y := round(x);


Accepted Solution

mertdogan earned 360 total points
ID: 8173132
Additionally you can use this procedure

Function CurrencyToInteger(CurType: Currency): Integer;
  i: integer;
  j: Comp;
CurrencyToComp(CurType, j);
LVL 17

Expert Comment

ID: 8177021

Just my 2 cents:
Currency type variables contain real numbers. Converting them to integer numbers will cut, truncate or round their values throwing the fractional parts away. How will you do this depends on what you want to achieve. Ask yourself the following questions and let us know the answers.

- do you need the integer part only (regardless of the fractional part)?
- do you need to round the integer part depending on the fractional part (if >= 0.50 then +1 to the result)?
- how the negative values have to be processed?

Regards, Geo

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

765 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