|
-
Nov 13th, 2002, 10:36 PM
#1
Thread Starter
Fanatic Member
base conversion
convert 9.75 to base two. there are a quiet few methods of doing it, one of them is really nice! so if you have a method not posted here, by all means post it!
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Nov 13th, 2002, 11:04 PM
#2
So Unbanned
-
Nov 13th, 2002, 11:12 PM
#3
Thread Starter
Fanatic Member
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Nov 13th, 2002, 11:42 PM
#4
So Unbanned
/me doesn't know how to represent a decimal in binary.
-
Nov 14th, 2002, 12:38 AM
#5
Fanatic Member
Easy...
9.75 = 9 + 3/4
= 8 + 1 + 1/2 + 1/4
= 1001.11
sql_lall 
-
Nov 14th, 2002, 07:15 AM
#6
Thread Starter
Fanatic Member
yep right answer. also, 9.75=39/4=100111/100=1001.11
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Nov 17th, 2002, 10:52 AM
#7
transcendental analytic
9%2=1
9\2=4
4%2=0
4\2=2
2%2=0
2\2=1
1%2=1
do integer division with radix until you get 1, append the modulo to string
0.75 * 2 = 1.5
0.5 * 2 = 1
0.11
I don't know if this works with other than base 2, multiply with with two until you get 1, if you get more than 1, append 1 in the string, subtract 1 from the result and start over, otherways append 0 to string.
1001.11
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 17th, 2002, 07:35 PM
#8
Addicted Member
The division by 100 was originally done by long division!
-
Nov 17th, 2002, 09:09 PM
#9
Thread Starter
Fanatic Member
Not many ppl could come up with such an ingenious method!
Massey RuleZ! ^-^__  Cheers!  __^-^ Massey RuleZ!
Did you know that...
The probability that a random rational number has an even denominator is 1/3 (Salamin and Gosper 1972)? This result is independently verified by me (2002)!
-
Nov 25th, 2002, 02:14 AM
#10
Frenzied Member
Convert fractions by muliplying by the new Radix.
Convert decimal .375 to binary.
Multiply by two: 0.75
Multiply fractional part by two: 1.50
Multiply fractional part by two: 1.00
Fractional part is zero, you are finished.
Take integer parts of each product in order: .011
If you try the above with a value like .37, you will never get exactly zero for the fractional part because .37 is a never ending binary fraction.
To convert integers, divide by radix and use remainder for the converted digits.
Convert decimal 28 to binary.
28/2 = 14, Remainder zero.
14/2 = 7, Remainder zero
7/2 = 3, remainder one
3/2 = 1 remainder one
1/2 = 0 Remainder one. You are done since quotient is zero.
Take remainders in reverse order: 11100
The above works for converting from any radix to any other, but requires doing arithmetic with some radix other than ten for some conversions. For example.
Octal .32 to decimal (Note that Ten = octal 12)
Ten * .32 (octal arithmetic) = 4.04
Ten * .04 = 0.50
Ten * .50 = 6.2
Ten * .2 = 2.4
Ten * .4 = 5.0
Decimal value is .40625
Use decimal arithmetic to convert back to octal.
Eight * .40625 = 3.25
Eight * .25 = 2.000
Result is octal .32
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|