LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-02-2005, 05:21 PM   #1
hubabuba
Member
 
Registered: Jan 2002
Location: UK
Distribution: Slack 14.1
Posts: 193

Rep: Reputation: 30
printing negative value as positive


Hi

I can't get this right.
A result of a subtraction of one int variable with positive value from another int variabe with positive value, produces a negative value and stores it in the third int value. How can i print the negative value as positve (without the minus sign)?

Thanks
 
Old 05-02-2005, 05:46 PM   #2
ahwkong
Member
 
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282

Rep: Reputation: 30
what language?

If the language provide abs() (absolute value), you can apply this to the neg num before printing.
 
Old 05-02-2005, 06:54 PM   #3
hubabuba
Member
 
Registered: Jan 2002
Location: UK
Distribution: Slack 14.1
Posts: 193

Original Poster
Rep: Reputation: 30
C Language.

I'm a begginer, I don't know if it provides abs() .
 
Old 05-02-2005, 08:45 PM   #4
ahwkong
Member
 
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282

Rep: Reputation: 30
Being beginner is no excuse for not looking it up yourself.

Using google and keyword "abs c" I found some reference right away.
 
Old 05-03-2005, 11:45 AM   #5
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 58
Just check if the number is negative. If it is then multiply it by -1.
 
Old 05-03-2005, 01:41 PM   #6
hubabuba
Member
 
Registered: Jan 2002
Location: UK
Distribution: Slack 14.1
Posts: 193

Original Poster
Rep: Reputation: 30
Thanks for your replies. Worked out how to use the abs().
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
core 4 (any positive??) Atrocity Fedora 5 07-08-2005 12:31 PM
'Chkrootkit 0.43' false positive? Mr. Gone Linux - Security 2 03-09-2004 10:16 AM
'Chkrootkit 0.43' false positive? Mr. Gone Linux - Security 0 03-08-2004 09:06 AM
Success!!! Positive story for other newbs Jason_NYC Mandriva 9 02-09-2004 08:45 AM
Positive Development: Knoppix Install Worked. rvijay Linux - Newbie 0 09-10-2003 01:33 PM


All times are GMT -5. The time now is 04:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration