How do I add binary numbers using ARM Assembly?
The assembly language that I"m using is ARM Assembly.
Would I use the ADD instruction to do so? Would I have to start by taking in a number in decimal and then using some instruction to convert the decimal number to binary?
Let's say that I have three numbers 33, 25, and 14. I want to add them all together. Say that the three numbers are stored in an 8bit array with binary numbers with three elements. After traversing through the array, would I have to convert the binary numbers to decimal and then add them? Or can I just add them directly using the ADD function?
What happens if I have to add two numbers that overflow the 8 bits? Say that I add 250 and 45 in which both numbers are in binary and stored in an array with its elements having 8 bits? How do I handle this?
See also questions close to this topic

Using 'this' inside angularjs service
I would like to know whether the following code is bad practice. (This code is a angularjs service def)
**NOTE: This code is working perfectly. but someone saying this is bad practice **
module.service('storageService', [function () { this.getValue=function(){//} this.computeExpiry=function(){ var activeRule=this.getValue() //using `this` to call getValue function is bad practice ?? } }]);
It would be appreciable somebody can give some insight.
1.) Is the above code wrong/bad practice?.
2.) Should I always proxy
that=this
in angular js services to call the function inside the same service3.) The above code lenient?
4.) "The above code causes unexpected bug because the services are injected in different execution contexts so the
this
will point to different context " how valid this statement how this affect. 
How do I compare an object of arrays to a user created object
I am comparing the user created object Date myDate to the array
myAppointments[i]
now it should return true if the values
month
,day
,year
are the same acrossmyDate
andmyAppointments[i]
the other valuesmyAppointments[i]
should not matter.Here is main
/* * Homework 4  UPDATE as needed */ #include <iostream> #include <fstream> #include <iomanip> #include <string> #include "Appointment.h" using namespace std; void callPrint (Time &TimeOrApptObject) { TimeOrApptObject.print();} int main(){ int month, day, year, hour, minute,howLong; Appointment myAppointments[19]; ifstream HW4DataFileHandle; HW4DataFileHandle.open("Lab6Data.txt"); while (!HW4DataFileHandle.eof( )) { for (int i = 1; i < 20; i++) { HW4DataFileHandle>>month; HW4DataFileHandle>>day; HW4DataFileHandle>>year; HW4DataFileHandle>>hour; HW4DataFileHandle>>minute; HW4DataFileHandle>>howLong; myAppointments[i] = Appointment( month, day, year, hour, minute, howLong); } cout <<"enter a month" <<endl; cin >> month; cout <<"enter a day" <<endl; cin >> day; cout <<"enter a year"<<endl; cin >> year; Date myDate( month, day, year); cout <<"Appointments for" << month <<"/" << day <<"/" << year <<":"<< endl; for (int i = 0; i <13; i++){ if ( myAppointments[i]== Date myDate ) { Time thisTime = myAppointments[i]; thisTime.print(); cout << endl; } } } }
Date.h
// Date.h  Class Date UPDATE as needed #ifndef DATE_H #define DATE_H class Date { private: int month; int day; int year; public: Date(int m, int d, int y) : month(m), day(d), year(y) { } Date() = default; friend bool friendTorCompare2Dates (const Date&,const Date& ); }; bool friendTorCompare2Dates (const Date& Right, const Date& Left) { if (Right.month == Left.month && Right.day == Left.day ) return true; else return false; } #endif
Time.h
//Time.h  Class Time UPDATE as needed #ifndef TIME_H #define TIME_H using namespace std; #include<iostream> class Time { private : int hour; int minute; public: Time(int h, int m) : hour(h) { } Time() = default; virtual void print() { cout << hour << " " << minute <<" " ; } }; #endif
Appointment.h
// Appointment.h  Class Appointment UPDATE as needed // #include "Time.h" #include "Date.h" #ifndef APPOINTMENT_H #define APPOINTMENT_H using namespace std; class Appointment: public Date, public Time { private: int howLong; public: Appointment(int month, int day, int year, int hour, int minute, int howLong) : Date(month, day, year), Time(hour, minute), howLong(howLong) { } Appointment() = default; }; #endif
What do I need to change or add so that
if ( myAppointments[i]== Date myDate )
works? Please include an example and if something needs added please indicate which bit of code it needs added to that would be much appreciated. Thank you for your time. 
Only getting "0" and "NAN" values in array?
I am trying to make a T2 map (array) from some dicom images, but my code is only producing a T2 map of "NAN" and "0" values. Here is the block of code I am currently working with:
# T2 Calculations T2_map = np.empty((number_of_segments, number_of_segments, number_of_segments)) for i in range(1, number_of_slices + 1): if 3 + (i  1) <= number_of_segments: I1 = (dcm_pixel_array["array" + str(3 + (i  1))]) * 2 else: I1 = (dcm_pixel_array["array" + str(number_of_segments)]) * 2 if 3 + ((7 * number_of_slices) + (i  1)) <= number_of_segments: I8 = (dcm_pixel_array["array" + str(3 + ((7*number_of_slices) + (i1)))]) * 2 else: I8 = (dcm_pixel_array["array" + str(number_of_segments)]) * 2 print("I1:", I1) print("I8:", I8) print("") for j in range(I1.ndim): for k in range(I1[0].ndim): if (I1[j][k]) == 0 or (I8[j][k]/I1[j][k]) <= 0 or (np.log((I8[j][k]) / (I1[j][k]))) == 0: T2_map[j, k, i] = "NAN" elif (3.03  (17.85 + 14.87)) / (np.log(I8[j][k] / I1[j][k])) < 0: T2_map[j,k,i] = 0 elif (3.03(17.85+14.87))/(np.log(I8[j][k] / I1[j][k])) > 100: T2_map[j,k,i] = 100 else: T2_map[j,k,i] = ((3.03(17.85+14.87))/(np.log(I8[j][k] / I1[j][k]))) print() print("T2 map:", T2_map) print()
The values in I1 and I8 range from 0 to 16, so this code should technically produce actual numeric values. Any recommendations as to how I should proceed with troubleshooting this problem?
Clarifications: number_of_segments = 288, number_of_slices = 36
Thank you! :)

Multiple Interrupt Levels Purpose
Wondering why multiple interrupt levels are needed...does it prevent memory corruption, allow the ability to run real time systems??
Does it allow to run high priority interrupts during low priority interrupts?

Is there a way to retrieve the full assembly execution trace of a C program?
I have a couple C programs that I basically want to disassemble. I was using objdump, but I realized that is static disassembly. Is there anyway to get the full assemblylevel trace of the program of the instructions executed in order? I am running on x8664.

when do use extension move instruction in assembly language
I saw
movw %dx (%eax)
on my textbook, and I'm wondering why usemovw
rather thanmovswl
ormovzwl
here?I think that there are 2 bytes in
%dx
and 4 bytes in(%eax)
(for a 32bit machine), so it needs an extension? 
Entensions from Binary Data
Is there any way to figure out the type of a file by just looking at the binary data? I tried using the magic number binary signatures, but they only distinguish if a file is a new or old Microsoft document or another type like a .tif. They don't distinguish .xlsx from .docx.

Big binary number
I'm trying to solve a problem, for the basic scenario it's working, nevertheless, I know that it is not optimal and has several faults.
Problem: You are given a number n. Find the decimal value of the number formed by the concatenation of the binary representation of the first n positive integers. Print the answer 10^9 + 7.
Output format: Print the answer modulo 10^9 + 7
Constraint: 1 <= n <= 10^9
Sample input: 3 Sample Output: 27 The binary representation of 1: 1 The binary representation of 2: 10 The binary representation of 3: 11 Concatenated string: 11011 > Decimal representation is 27.
The first doubt that I have is: "modulo 10^9 + 7", I understand is the limit for the number of chars, but I don't know how to interpret it.
The second part of the question is with the solution: Input: 20
Binary representation of 2 : 10. Binary representation of 3 : 11 Binary representation of 4 : 100. Binary representation of 5 : 101 Binary representation of 6 : 110 Binary representation of 7 : 111 Binary representation of 8 : 1000 Binary representation of 9 : 1001 Binary representation of 10 : 1010 Binary representation of 11 : 1011 Binary representation of 12 : 1100 Binary representation of 13 : 1101 Binary representation of 14 : 1110 Binary representation of 15 : 1111 Binary representation of 16 : 10000 Binary representation of 17 : 10001 Binary representation of 18 : 10010 Binary representation of 19 : 10011 The binary representation of 20: 10100 Concatenated string: 11011100101110111100010011010101111001101111011111000010001100101001110100
How would you recommend to tackle this kind of problem?

Spatial modeling of binary response outcome
I am modelling dichotomous response data to explain geographical variation in my data. I have attached my method and below is a brief description of my model;
Yik follows a Bernoulli distribution for a child k located in state i = 1, ...,37 with response either 0 or 1. We added structured and unstructured random effects to account for unobserved influential factors that vary across the state. I have run my code;
Formula< yik~x1+...+xn+f(NAME_1a,model="besag",graph="Map.adj")+ + f(NAME_1b,model="iid") > Analysis<inla(Formula + ,family="binomial" + ,data=dat + ,control.compute=list(dic=TRUE, cpo=TRUE)),
but got this message;
Error in inla(Formula, family = "binomial", data = dat, control.compute = list(dic = TRUE, : In f(NAME_1a): 'covariate' must match 'values', and both must either be 'numeric', or 'factor'/'character'.
In order to rectify the error, I run the following code also,
m = get("inla.models", INLA:::inla.get.inlaEnv()) m$latent$rw2$min.diff < NULL assign("inla.models", m, INLA:::inla.get.inlaEnv())
But this particular one,
m$latent$rw2$min.diff < NULL
brought out this error;"Error in `*tmp*`$latent :` object of type 'closure' is not subsettable"

problem in formatting decimal places python
if __name__ == '__main__': n = int(input()) student_marks = {} for _ in range(n): name, *line = input().split() scores = list(map(float, line)) student_marks[name] = scores query_name = input() if query_name == name: print("{:.2f}".format(sum(scores)/len(scores)))
I want the result to be show in 2 decimal places such as 56.00

How to compare two decimals with 0 and 0.00
I have two decimal values. I want to compare those and want return false
decimal x =0; decimal y= 0.00 or 0.0m; i want show if (x== y) // false or x.equals(y) // false i tried many ways i could find solution.

Datediff to get a month year in decimal
So this is what i have:
CAST(DATEDIFF(month, a.LstPaymentDte, a.createdte)/12 as DECIMAL(10, 1)) AS diff_in_month
Example: a.LstPaymentDte = 6/13/2019 and createdte = today
I want the value output to show 1.1, so the year would be 1 and the month would be .1
Any thoughts on what I need to do?

Is postorder traversal == bottomup traversal and preorder traversal == topdown traversal?
Would it be right to say postorder traversal of a tree should be used to do a bottomup traversal whereas a preorder traversal should be used to do a topdown traversal of a binary tree?
This has been true in all the examples that I have encountered, so I just wanted to confirm. There are some problems for which it is intuitive to start from the leaves (at the bottom). Can we use postorder traversal to solve them (and vice versa)?
Thanks!

Cause of Infinite Loop? (iterative inorder traversal implementation) C++
Question: Implement Inorder Traversal iteratively.
My Attempt: (results in an infinite loop that I haven't been able to debug) any help or suggestions greatly appreciated
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {} * }; */ #include <vector> #include <stack> #include <unordered_set> using namespace std; class Solution { public: vector<int> inorderTraversal(TreeNode* root) { //iterative sol: vector<int> sol; stack<TreeNode*> dfs; dfs.push(root); unordered_set<TreeNode*> visited; visited.insert({root}); TreeNode* temp; while (!dfs.empty()) { if (dfs.top()>left != nullptr && visited.find(dfs.top()>left) == visited.end()) { dfs.push(dfs.top()>left); visited.insert({dfs.top()>left}); } else { sol.push_back(dfs.top()>val); temp = dfs.top(); dfs.pop(); if (temp>right != nullptr && visited.find(temp>right) == visited.end()) { dfs.push(temp>right); visited.insert({temp>right}); } } } return sol; } };
EDIT: I don't have the specific internal definitions of the TreeNode, but if you want to run the problem, checkout: https://leetcode.com/problems/binarytreeinordertraversal/

Traversing a vector of list
/* struct represents edges for a directed graph */ struct Edge { public: Edge(int aTo = 0, int aCost = 0) { to = aTo; cost = aCost; } int to; int cost; }; /* Graph object is used store graph using adjacency list method and implements Dijkstra's Algorithm to produce the shortest path from vertex s to all other vertices */ class Graph { public: vector<int> Dijkstra(int src) const { // My method (stated below) goes here } private: ... vector<list<Edge> > adjacencyList; }
My question then is how do I traverse a list of edges in order to insert into a heap?
For example ( Note: (#) represents index of vector array), let's say we have 3 vertices and adjacency List representation is the following:
(0) 0 > 1 > 2 > null (1) 1 > 2 > null (2) 2 > null
I want the first vertex, vertex 0, and want to access the vertices 1 & 2 to retrieve the cost to get to each to put on another data structure (i.e. heap).
My approach was the following:
for (auto it = adjacencyList.at(0).begin(); it != adjancencyList.at(0).end(); it++) { // use it pointer to access each vertex's cost }
this produces error:
Value of type 'std::__1::__list_const_iterator<Edge, void *>' is not contextually convertible to 'bool'
Let me know if more clarification needed.