Computing.Net > Forums > Programming > Where's the TRUNC func? (C++)

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Where's the TRUNC func? (C++)

Reply to Message Icon

Original Message
Name: Leo the 28C (by Sulfurik)
Date: September 4, 2005 at 15:41:31 Pacific
Subject: Where's the TRUNC func? (C++)
OS: Windows XP Home SP2
CPU/Ram: 2.8 GHz/448 MB
Comment:

Hello everyone! :D
OK, I read on a forum post that there was a "trunc" function in the "std lib" that removed decimal points off numbers... The problem is that this function doesn't exist!

Look at my code:

----------
#include <iostream.h>
#include <stdlib.h>

int main()
{
int age; // Age variable
cout << "Hello there!\n";
cout << "Please type in your age: ";
cin >> age;
cout << "Good, good... You'll die when you're " << trunc(age * 1.5) << " years old! HAHAHA!!!";
}
----------

That function doesn't exist! I searched for it at http://www.cplusplus.com/ref/ but I didn't find it... Is there a FULL library reference out there that I can use? Can anyone help me? Thanks! ;)

PS#1: The forum post:
http://forums.devarticles.com/t10032/s.html

PS#2: I'm using Borland's free C++ compiler.

PS#3: I hope not to die at the age the program told me...

http://www.xthost.info/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Ruffle Mayo says ROFLMAO! :D


Report Offensive Message For Removal


Response Number 1
Name: gimmpy225
Date: September 4, 2005 at 17:17:38 Pacific
Reply: (edit)

trunc is part of the ms visual C++ lib i think, not sure though so dont hold me to it.

GIMPS


Report Offensive Follow Up For Removal

Response Number 2
Name: gimmpy225
Date: September 4, 2005 at 17:20:06 Pacific
Reply: (edit)

ios::trunc If the file already existed it is erased

found that for C++

GIMPS


Report Offensive Follow Up For Removal

Response Number 3
Name: Leo the 28C (by Sulfurik)
Date: September 4, 2005 at 18:17:22 Pacific
Reply: (edit)

Yeah, it probably was for VC++... Thanks! ;)

http://www.xthost.info/sulfurik/
http://tsfc.ath.cx
ftp://tsfc.ath.cx
hotline://tsfc.ath.cx

Ruffle Mayo says ROFLMAO! :D


Report Offensive Follow Up For Removal

Response Number 4
Name: syvjackson
Date: September 5, 2005 at 20:09:47 Pacific
Reply: (edit)

This is for Rimfire! Nothing seems to be working. I'm ready now to throw in the towl and take this thing to someone smarter than I. Thanks for all your help, your wonderful patience and time. You guys are great.
syvjackson


Report Offensive Follow Up For Removal

Response Number 5
Name: gimmpy225
Date: September 5, 2005 at 21:32:19 Pacific
Reply: (edit)

what ya having problems with syv, sry for using your post to talk sulfur lol

GIMPS


Report Offensive Follow Up For Removal


Response Number 6
Name: timmay024
Date: September 27, 2005 at 09:17:03 Pacific
Reply: (edit)

This might be kind of late but if you want to take a number like 123.456 and just get rid of the .456 then you can declare a int and set it equal to your decimal.


int num;
double dec = 123.45;

num = dec;
cout << num;
will give 123


Report Offensive Follow Up For Removal






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software