Re: [Tutor] Binary Real to Decimal

2009-03-30 Thread Dave Angel
I don't know what "sufficient numbers" means, but perhaps it's "significant digits" that was intended. And you have to decide if you want ten digits to the right of the decimal point, or ten significant digits in the whole number. That determines whether you want to round decnum2 or the final

Re: [Tutor] Binary Real to Decimal

2009-03-30 Thread spir
Le Sun, 29 Mar 2009 22:42:43 -0500, Chris Castillo s'exprima ainsi: > myinput = raw_input("Please enter a binary real number: ") > myinput = myinput.split(".") > > binstr1 = myinput[0] > binstr2 = myinput[1] > > decnum1 = 0 > decnum2 = 0 > > for i in binstr1: > decnum1 = decnum1 * 2 + int

Re: [Tutor] Binary Real to Decimal

2009-03-29 Thread John Fouhy
2009/3/30 Chris Castillo : > yeah that function would help but how would I join both sides again to get a > decimal real(float) to round? > > for example myfloat = decnum1, ".", decnum2 doesn't work because the string > "." isn't a valid int type. how would I join those to be a float again? The ea

Re: [Tutor] Binary Real to Decimal

2009-03-29 Thread Chris Castillo
yeah that function would help but how would I join both sides again to get a decimal real(float) to round? for example myfloat = decnum1, ".", decnum2 doesn't work because the string "." isn't a valid int type. how would I join those to be a float again? On Sun, Mar 29, 2009 at 10:46 PM, John Fou

Re: [Tutor] Binary Real to Decimal

2009-03-29 Thread John Fouhy
2009/3/30 Chris Castillo : > that is what I have so far but I need to create a condition where I need > only 10 sufficient numbers from the variable decnum2. I know I need > something like > if len(decnum2) > 11: >     decnum2 = decnum2[0:11] Perhaps the round() function will help? >>> round(1234

[Tutor] Binary Real to Decimal

2009-03-29 Thread Chris Castillo
myinput = raw_input("Please enter a binary real number: ") myinput = myinput.split(".") binstr1 = myinput[0] binstr2 = myinput[1] decnum1 = 0 decnum2 = 0 for i in binstr1: decnum1 = decnum1 * 2 + int(i) for k in binstr2: decnum2 = decnum2 * 2 + int(k) print "\nThe binary real number