Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Truncate after decimal

Status
Not open for further replies.

XNOR

Programmer
Nov 15, 2001
17
US
Trying to cut down a float to the hundredth position as in cents.

Borland mentions TRUNC, Trunc, Truncate and the such. The error says undefined func and including math.h doesnt help.

Let me know if you know whats up or of you have a unique way of doing this.

hrmmmm, well, i could clip the whole number, multiply by 100 and then clip the decimal, divide by 100 and add it to the whole number... arrgg, but i dont wanna! ;)
 
well shoot... i forgot that even if i wanted to cut off those decimal places with my method, the float still prints the remaining 5 gazillion zeros. :(

Now i wonder if its possible to truncate a float and still use it as a float. What i mean is id have to have a truncfloat or truncf in order to have a variable with the decimal properties i want.

i hope you guys understand what im babbling on about
 
I've never been able to get truncate to work. I've defined a function that does what you've described except that I take the number to an integer to clip it. Sorry, not what you wanted to hear. :-( James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
thats ok m8. i created a function that took the float and made an int of the whole number and first two decimal places.
Then it puts the two into a string so i can include the decimal point.

l8r
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top