How do I convert 234.35 into Binary? [closed] - binary

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I need to convert the above into Binary. I'm at a loss here.
Can you include full information on how you got the answer too?.
Step by step would be great!

First, convert the integral part which is 11101010. Next, you build the decimal part. If demonstrated informally, it is something like:
0.1 is one half, but 0.35 is less than that, so the first binary digit is zero -> .0 (0.35)
0.01 is one quarter, and 0.35 is greater than that, so then follows one. 0.35 minus one quarter is decimal 0.1 -> .01 (0.35 - 0.25 = 0.1)
0.001 is one eighth, and decimal 0.1 is less than that, so again zero -> .010 (0.1)
Next steps are: .0101 (0.1 - 0.0625 = 0.0375); .01011 (0.0375 - 0.03125 = 0.00625); then follow two zeroes, and we can probably cut it here.
So, the answer is 11101010.010110... As the original number has decimal part of 7/20, it becomes infinite when converted to binary.

Related

Prove that not all ternary linear codes contain the all zero codeword [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 days ago.
Improve this question
I have to prove that not all ternary linear codes contain the all zero codeword.
Some term explanations:
A linear code is a code that the sum or difference of any two codewords must also be a codeword. In other words, for all x, y in C, x +/- y is also in C.
A ternary codeword in this exercise is a codeword containing 0, 1 or 2. Eg, 1011, 1012, 012, ...
An all zero codeword is something like 0000, 000, 00000, ...
My attempt:
The addition of codewords must be done MOD 3 which means there are three allowable numbers in this MOD 3 world including 0, 1 and 2. For any ternary linear codes, there are cases when all the additions of any two codewords yeild non-zero codewords.
I am not sure about the proof. I have an idea that it must deal with the MOD 3 but not sure how to explain.
Thank you so much!

Octave least squares approximation [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
So i've got a task.
That's here:
What values does the model F (t) = x(1) + x(2)*t^2 + x(3)*sin(π*t)
best fit in the least squares sense of the following data take place
at 1.0? t=[0.1 0.3 0.4 0.8 0.9] f=[2.06 2.91 3.19 3.16 2.89]
t=[0.1 0.3 0.4 0.8 0.9]';
f=[2.06 2.91 3.19 3.16 2.89]';
A=[ones(5,1),sin(pi*t)];
x=(A'*A)\(A'*f)
xx=linspace(0,1.0);
yy=x(1)+x(2).*xx.^2+x(3).*sin(pi.*xx);
figure; plot(t,f,'*',xx,yy)
I wrote this code and got an error
called from
code.m(example) at line 6 column 3
I think you can use pinv to solve x, i.e.,
m = [t.^0;t.^2;sin(pi*t)];
x = f*pinv(m);
such that
>> x
x =
1.5760 1.0504 1.5286
Data
t=[0.1 0.3 0.4 0.8 0.9];
f=[2.06 2.91 3.19 3.16 2.89];

Convert a negative number with a fraction in 2's complement [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 3 years ago.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Improve this question
I want to convert number -0.25. So 0.25 (for 4 bit int and 4 bit frac) equals to:
0000_0100
For negative number -1 answer is
1111
But what is -0.25? How can I convert this negative number with a fraction in 2's complement?
To answer this question, I need to clarify that the numbers are represented in a fixed-point. Almost all logic nowadays uses two's complement. Therefore, in the two's complement version negative numbers are considered for example:
signed 4'b1100 = -4 (-1*2^3 + 1*2^2 + 0*2^1 + 0*2^0).
Number for example 0.25 in fixed-point binary will be represented:
8'b0000_0100 (int 4 bit is zeros and frac 4 bit -> 0*2^-1 + 1*2^-2 + 0*2^-3 + 0*2^-4).
Other way to calculate can be multiply the number to integer find negative and then divide this number (remember, that multiplication on 2 is shift to the right, and division on 2 is shift to the left).
For my example -0.25 would be as follows:
-0.25*2*2= -1.
-1 = 4'b1111.
shift 2*2 to left = 4'b11_11 = -0.25.
Or we can calculate: -1*2^1 + 1*2^0 + 0*2^-1 + 1*2^-2.
1 in MSB is signed bit. We must remember this when operate with signed logic.

function in Haskell that can solve an equation [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to write a function in Haskell that can solve the following problem(physic_problem):
What is the height (in a whole number of meters) of the shortest building that you could drop a ball from such that it would take at least 5 seconds to hit the ground?
The equation can be found here http://en.wikipedia.org/wiki/Equations_for_a_falling_body
I really tried hard on this and i need help!
Thank you so much!
Consider for instance this,
g :: Double
g = 9.81
dist :: Double -> Double
dist t = g * t^2 / 2
Then,
> dist 5
122.625
Additionally you may want to create a module out of the equations in that Wiki.
Update
For delivering an integral value consider for example
dist' :: (Integral a) => Double -> a
dist' t = ceiling $ g * t^2 / 2
Here we use ceiling (upper bound), yet note Converting to Integral for other rounding functions. Hence,
> dist' 5
123

How to store longitude and latitude in database. MySQL won't go further than -99.9999999 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Ok right now I'm storing lat and lng columns as DECIMAL(10,8)
I'm trying to insert this:
-117.1779216 However it keeps inserting as this : -99.99999999
Why is this? I see every other board storing it as DECIMAL, but it won't go back more when I'm giving it 10 places before the period... So I would think it could go -117.. None of them are marked as unsigned either.
Precision (10) - Scale (8) = 2
2 is the number of digits you can have to the left of the decimal
If you increase the precision, you can have more digits to the left of the decimal.
The declaration syntax for a DECIMAL column is DECIMAL(M,D). The ranges of values for the arguments in MySQL 5.1 are as follows:
M is the maximum number of digits (the precision). It has a range of 1 to 65. (Older versions of MySQL permitted a range of 1 to 254.)
D is the number of digits to the right of the decimal point (the scale). It has a range of 0 to 30 and must be no larger than M.
Taken from the manual :D
You set it to DECIMAL(10,8) with the number -117.1779216. MySQL reads this as -117.17792160 because it needs 8 digits of precision, but you said it should only have 10 digits, so anything over 99 makes it 11 digits and invalid.