Binary subtraction using the direct way
Why is 01101.101  11011.110
equal to 1110.001
and not 110001.111
whereas 10101.101  01011.110
is equal to 1001.111
. The numbers after the decimal are the same but the first number gets me 0.001
yet second number is equal to 0.111
.
See also questions close to this topic

Append to binary file row by row and column by column efficiently
I am solving N coupled differential equations (u1(t),v1(t),u2(t),v2(t),...) iteratively. I am trying to improve the efficiency by not saving all of my iteration steps into lists, but instead exporting my results for every 10th time step into a binary file which I later import so that I can plot the results over time. This ultimately involves updating the binary 1st row, 1st column, then 1st row, 2nd column, ..., then 2nd row, 1st column, etc. At the end I want the lists u1(t), v1(t), u2(t) ...
This is my attempt:
import numpy as np dt = 0.001 ts = np.arange(0, 30, dt) P, N = 2, 4 u = v = np.array(np.zeros(N)) with open('oscillators.bin', 'wb') as f: for t in range(len(ts)): osc_list = [] for j in range(P,P+1): u[j] += (u[j]  (u[j]*u[j]*u[j])/3  v[j])*dt v[j] += (u[j] + 1.05)*dt + np.random.normal(scale=np.sqrt(dt)) if not t % 10: osc_list.append(u[j]) osc_list.append(v[j]) if j==P: np.save(f, osc_list) fp = open("oscillators.bin", 'rb') a = [] for i in range(int(len(ts)/10)): a.append(np.load(fp)) A = np.array(a) ## u1, v1, ... = A[:,0], A[:,1], ...
The real numbers for my parameters are very very large. My question is, can this be code be made simpler and more efficient?

How to convert binary sum to binary in O(n)
I am trying to find an optimal solution for convertimg binaries to binaries. I am keeping large numbers in an array using powers of 2 and keeping a sum.For example I am keeping the number $2^{3} + 4x2^{2} + 5x2^{1}$ = 29 in an array of 4 as this {0,5,4,1} where each place of the array has the times that each power of two appears. After my program finishes I want to convert this array in an array that produces the same sum but has only one or zero in the array. In ither words I want to convert this sum to binary. So my example would give the array {1,0,1,1,1} = 29
How could I do this conversion in c ++ in O(n)
My current solution is O($n^{2}$) and is the following:
bool bl = true; while (bl) { for (int i = 0; i < M; i++) { if (num[i] != 0 && num[i] != 1) { vector<long int> p = block(num[i]); num[i] = 0; for (auto j = 0; j < p.size(); ++j) { if (p[j]!=0) num[j + i] += 1; } } } bl = false; for (int i = 0; i < M; i++) { if (num[i] == 0  num[i] == 1) { bl = false; continue; } else { bl = true; break; } } } for (int i = 0; i <= M; i++) { cout << i << ':' << num[i] << '\n'; }

Binary API documentation via swagger
I'm building an API that's able to upload multiple files at once. I need to document it through swagger, but I have no experience with it at all. My schema for the API is as follows:
The http request body is an octetstream that looks like this. The first 4 bytes represents the number of packages, let the number of packages be n. The next 4*n bytes represents the sizes of the packages, where the first 4 bytes is the size of the first package, the next 4 is the size of the second package, etc. The end of the request simply consists of the packages.
An example would be: The packages
\xDE\xAD\xBE\xEF
and\xFE\xED\xFA\xCE\xCA\xFE\xBE\xEF
, would compose the request:\x00\x00\x00\x02\x00\x00\x00\x04\x00\x00\x00\x08\xDE\xAD\xBE\xEF\xFE\xED\xFA\xCE\xCA\xFE\xBE\xEF
I've tried documenting this in swagger like this:
Batch: type: object properties: header: description: The number of packages represented in binary (big endian). type: string format: binary maxLength: 8 minLength: 8 example: \x00\x00\x00\x02 subheader: description: The size of each package, where the size of the first package is represented by the first 4 bytes, the second by the next 4 bytes, etc (big endnian). type: string format: binary maxLength: 4294967295 minLength: 0 example: \x00\x00\x00\x04\x00\x00\x00\x04 data: description: The data block for encryption/decryption type: string format: binary maxLength: 18446744073709551616 minLength: 0 example: \xDE\xAD\xBE\xEF\xDE\xAD\xBE\xEF
But it shows the request body as a json object (due to
type: object
). Any ideas on how to do this properly? 
Are there any design patters that can only be used for dynamically typed languages and not for statically typed languages?
Since statically typed programming languages do type checking (verifying and enforcing the constraints of types) at compiletime, one has to ensure type consistency at compilation stage itself.
However, for a language like Python, we can leverage different behaviours for different data types at runtime by making use of functions like
isinstance()
What I want to know about is has anyone been able to come up with a design patter (even for a specific use case) that is not possible to be implemented in a statically typed programming language?

Can anybody suggest good books to get a good idea of programming?
I'm new to the programming world and I'm not a CSE student, but I'm highly interested in learning programming and computer and web technologies. Have basic knowledge of general computing and using contemporary internet tools.
Dream to be a developer.
Thanks Priyashis.

How can I include sound into a project on bluej by URL?
I have a project due tomorrow for school and I'm a little confused on how I add sound to it. Our class works on the bluej platform, and the sound needs to be added by URL and not by a file on our computer, so that when the teacher runs it he can hear the music. We are doing an applet project, if that makes any difference. I have seen many demonstrations online of how to add sound to a project, but none on how to add a sound from a URL, and I am desperate for help. Thanks