Jump to content

octal

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
jamesw

jamesw

    Newbie

  • Members
  • PipPip
  • 12 posts
Hi. I have a 10 numeral system number -26 and I want to convert it to binary. I have done it, and I think it should be 1111 1111 1110 0110. Am I right?

and 2.15 to binary - I think that is 00000010.1500000000000001 ?

And is it possible to convert letters and numbers to octal/8 number system?? For example Ttcs08 to octal? If that is possible, what that would be?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I'll answer your last question first: octal is a mechanism for representing NUMBERS. It does not apply directly to text (though it can apply to the ASCII code for text).

The key to understanding Octal is to realize that it represents an alternative representation for numbers. In decimal, 1025 is code for (calculated using decimal notation): 1*10^3 + 0*10^2 + 2*10^1 + *10^0. This is because decimal is base 10.

1025 in octal would represent (again, calculated in base 10): 1*8^3 + 0*8^2 + 2*8^1 + 5*8^0. The same process can be applied if you have digits after the decimal point (so 26.15 in octal means 2*8^1 + 6*8^0 + 1*8^-1 + 5*8^-2).

You can do the same type of thing with binary (base 2). One major restriction is that you CANNOT have a digit with a value equal to or higher than your base. So 10.15 cannot be binary. For frame of reference: n^0 = 1 (assuming n is not 0). n^-m = 1/(n^m), so 2^-3 = 1/8 or .125.

This can cause some strange behaviors: such as 1/3 is 0.3333333333333333...in decimal, but it's 0.1 in base 3.

That all said, your -26 appears to be the 2's complement representation (binary uses signs) of -24 in a 16 bit system. Your binary of 2.15 is necessarily incorrect because you cannot use a 5 in your result.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
jamesw

jamesw

    Newbie

  • Members
  • PipPip
  • 12 posts
thanks.

so, no letters and numbers in octal system. or in ascii-code.

all right, 2.15 isn't possible, but what about 2.14?, can it be converted?
I want to represent integer, 2, in 2's complement representation and .15 in other way.

So, my -26 was right?, it should also be the 2's complement representation.

I'm really close, I know. Great if you advice once more!

Edit

I mean, .14 in other way ( not .15 )

Edited by TkTech, 02 November 2008 - 06:24 AM.
Do. Not. Double. Post.


#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
I didn't say 2.15 can't be converted, just that your conversion was incorrect.

I believe that 1111 1111 1110 0110 is actually -24.

You need to be aware that there is a HUGE difference between the numeric base system and the machine representation of the same base system. 2's complement only makes sense when you have a fixed number of bits. Binary has infinitely many bits available (though you can only use finitely many on the left side of the decimal point).
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog