473,395 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Sign-Magnitude Method of a signed 16bit int

158 100+
I am running in Linux x86 and I am wondering if there is a way to specify to use the Sign-Magnitude Method for representing a signed 16bit int.

When i use int16_t as a data type it does not use that method but I need it to.
Dec 9 '10 #1

✓ answered by donbock

No. C/C++ neither reveal nor allow you any control over the underlying representation of signed numbers.

6 4696
Raj K
9
Can you elaborate your question. I did not understand your requirement.
Dec 9 '10 #2
weaknessforcats
9,208 Expert Mod 8TB
Both C and C++ use sign magnitude. It's a fancy way of saying the left bit is the sign bit. When the left bit is ON you have a negative number.

BTW: Negative values are usually 2's complement. Postive values are not.
Dec 9 '10 #3
donbock
2,426 Expert 2GB
The most common technique for encoding signed integers is two's complement. However, it is not the only way to do it. One of the other techniques is signed-magnitude. In signed-magnitude encoding, the bit patterns for +n and -n differ only in the single sign bit. The question is whether this is what kardon33 meant by signed magnitude.
Dec 9 '10 #4
kardon33
158 100+
Thanks for the replies.

Yes DoBock, I am trying to use the signed-magnitude method.

Currently when I run my program it is not encoded in that method. I am wondering if it is possible to specify the encoding method.

Currently I am using a work around by using an unsigned 16bit and limiting the domain to 0-32767 and then manually setting the first bit using bitwise operations.

How ever this could lead to errors without strict checking what im setting.
Dec 9 '10 #5
donbock
2,426 Expert 2GB
No. C/C++ neither reveal nor allow you any control over the underlying representation of signed numbers.
Dec 9 '10 #6
kardon33
158 100+
Alright, thanks!
Dec 9 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: John Dunlop | last post by:
Q: What does @ (at-sign) do? A: @ is an operator, which, when prepended to an expression, suppresses error messages. Example: ...
12
by: tarmat | last post by:
sorry for this silly little question, but whats the function to grab the sign of a value?
37
by: Claude Gagnon | last post by:
Hi, How can we compare sign of numbers in C++ ? Bye, Claude
4
by: ben | last post by:
Hi all, I have a simple PHP page that takes values from a form and puts them in a database (MySQL). The code is in a file test.php, which I have typed in at the bottom of this post (please...
0
by: Emil Georgiev | last post by:
Hell I have a Web Custom Control project in ASP.NET. I'm using a subclassing technique to add functionality in HyperLink web server control. I want to create a property "BrowserWindow" of my...
6
by: Jason Heyes | last post by:
Does a function exist in the standard library to compute the sign of an integer? Example: int sign(int v) { return v > 0 ? 1 : (v < 0 ? -1 : 0); } Thanks.
7
by: kingski | last post by:
Any idea about this ? http://www.developerfusion.co.uk/forums/thread/114379/#114379 "Can any one help me as i am building a shopping cart and it supports multiple currencies but while sending...
4
by: Jai | last post by:
Hi, I have a problem related to Login System. I am developing 3 websites for some institution.Now they want that if anybody had sign up for there site1.com(say), than he or she should be able...
6
by: Steve K. | last post by:
I recall a few months ago coming across an article allowing for encoding (or converting?) xml and html documents into sign language as well as brail for deaf and blind people, and that they were...
20
by: Ravikiran | last post by:
Hi Friends, I wanted know about whatt is ment by zero optimization and sign optimization and its differences.... Thank you...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.