LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 02-17-2004, 02:51 PM   #1
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Rep: Reputation: 38
int(char(254)) becomes


-2

I got a bug. I don't believe this!

how do I translate between chars and ints so they are between 0 and 255?

Maybe I should make my own methods.
 
Old 02-17-2004, 03:29 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
By default, char is unsigned. 254 in an unsigned char is 254 in a signed char it is -2.

No bug.
 
Old 02-17-2004, 03:35 PM   #3
kalleanka
Member
 
Registered: Aug 2003
Location: Mallorca, Spain
Distribution: xubuntu
Posts: 551

Original Poster
Rep: Reputation: 38
a bug in my program.

I will try to use the unsigned!
 
  


Reply



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
C programming - Char to Int Conversion ? indian Programming 4 09-30-2005 08:00 AM
char to int: a twist Guru3 Programming 5 12-05-2004 08:49 AM
Converting int value to char liguorir Programming 8 05-23-2004 07:21 PM
Char array to int without losing value ? Dimitris Programming 3 01-14-2004 12:08 PM
int, long in char * marek Programming 10 09-01-2003 10:43 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:16 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration