Go to Post Robotics. Seems to be the answer to a lot of things I don't do. - Keith Chester [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 05-01-2008, 22:23
dmlawrence dmlawrence is offline
MIT '14
FRC #1751 (Warriors)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Long Island
Posts: 63
dmlawrence is an unknown quantity at this point
Question Signed and unsigned variables

What is the proper method to cast from an unsigned to a signed variable?

For example, suppose that u is an unsigned int and i is a signed int.

When u is 0, i should be -32768.
When u is 32768, i should be 0.
When u is 65535, i should be 32767.

Which of the following is correct:
i = (unsigned int) u or
i = (unsigned int) (u - 32768)?

Thanks,
David
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
pic: Dean and Woodie Signed Saftey Glass andrew348 Extra Discussion 8 27-03-2007 16:36
Labview dashboard and multiple variables Joe Ross LabView and Data Acquisition 2 15-03-2006 21:55
Math.h and Functions and Variables amateurrobotguy Programming 1 26-02-2005 03:19
problems assigning unsigned chars in FRC Code LoyolaCubs Programming 6 26-01-2004 23:21
My team is registered and signed up for Rutgers(rookie)! Erodge General Forum 5 11-10-2002 10:13


All times are GMT -5. The time now is 21:10.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi