Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

representing binary number naturally

33 views
Skip to first unread message

Prometheus

unread,
Sep 26, 2022, 7:31:40 AM9/26/22
to
# REPRESENTING BINARY NUMBERS NATURALLY.

What is the Problem?
-------------------
In Computer Science, we have various ways to represent numbers.

However,we have to choose the best way to represent numbers.This is especially true in strongly typed high level abstract languages like C/C++/Java etc.Futhermore, computer sciencient developed a binary number system called two complement;it is used to perform arthematic on binary numbers which can be transferred to other systems.This include decimal(base 10), hexadecimal(base 16), octal(base 8) etc.Two complement enables us to represent negative numbers with a signifance of the right most bit being a 1.

Is there a data structure and algorithm extension of two complement that handle overflow in such way that is indiscremnint of the type of data(binary number type) provided not occupy memory thier should not?

For example,and 8 ,and 16 bit can be stored together under one class(blueprint for an object) and support the performing of operations that will not result any overflow. The importance of this data structure is that binary number should apper naturally looking and be more effient as if their were represented as regular numbers , not taking memory their should not occupy.

Lew Pitcher

unread,
Sep 26, 2022, 10:11:49 AM9/26/22
to
Sorry, guy, but comp.lang.c is not the place to discuss this
sort of thing. Why don't you try comp.theory ?

(Followups set to comp.theory)
--
Lew Pitcher
"In Skills, We Trust"

Bart

unread,
Sep 26, 2022, 10:11:55 AM9/26/22
to
8-bit and 16-bit integers will usually occupy one byte and two bytes
respectively. They're not going to use any more memory than that, on any
sane byte-addressed machine, which is nearly all of them these days.

Overflow (both signed and unsigned) can be usually detected by processor
flags, but this is up to the language to take care of.

In C, unsigned overflow is legal behaviour, and signed overflow is
undefined.

For anything different, you need to program it yourself. Or some C
compilers have options to detect and trap signed overflow.

Do you have a particular problem to solve, or are writing an article
about the subject, or just quoting one?
0 new messages