A list of puns related to "Arithmetic Operations"
Iβm designing a basic 16-bit CPU with a register-memory architecture. Iβd like to be able to address memory locations directly when doing arithmetic rather than having to waste an extra CPU cycle every time for indirect addressing. Say I want to do arithmetic with values from two memory locations M1 and M2 and the result is stored in memory locations M3. If Iβm specifying the memory addresses in the operand, then naively I would expect the minimum size to be 48-bits! Could I compress the operand potentially or should I just use indirect addressing instead? Thanks
I went to a local safari park and part of the educational shows that they have there is dolphin shows where they show off what dolphins can do like how they make sounds to communicate to each other, doing flips and such. Among the tricks was they asked a member of the audience to provide an arithmetical operations (additions, subtractions, multiplications, divisions) with the limitation that the results should be 1 to 10. The trainers will then write the operation on a small blackboard, point it out to the dolphin and the dolphin will swim around and splash their horizontal fins as many times as the answer. The audience will count along with the number of splashes. There's usually two math problems presented to different dolphins. The first doplhin usually gets the answer right, while the second one fails at the first attempt then gets the correct answer at the second attempt.
So does the dolphin really read the blackboard and actually did the arithmetic operations or its actually looking/listening to other cues from the trainers?
I basically ran some performance test to compare int64, int32 and double operations (addition, multiplication, division, mod). Here noticed that int64 operations are around 50 times slower than int32 which is rather surprising. In particular I have noticed such a behaviour for simple additions which take the same time on a hardware level.
Is this a problem of the JIT or does Matlab introduce overhead for int64?
%warmup
test_collatz(10000);
tic
test_collatz(100000)
toc
function test_collatz(n_start_max)
for ii=1:n_start_max
collatz_fct_uint32(ii); % replace with uint64 function
end
end
function collatz_fct_uint32(n_start)
n = uint32(n_start);
while n ~= 1
if mod(n,2) == 0
n = n/2;
else
n = n+n+n + 1;
end
end
end
function collatz_fct_uint64(n_start)
n = uint64(n_start);
while n ~= 1
if mod(n,2) == 0
n = n/2;
else
n = n+n+n + 1;
end
end
end
Profiler result for n = n+n+n+1;
uint32: 3846914 calls, 0.125s total time
uint64: 3846914 calls, 7.118 total time
Other fun facts:
bitshift is ~10 slower than n/2
https://preview.redd.it/qegoa3tb9tx71.png?width=686&format=png&auto=webp&s=f81f6a76c454053d6b352a2bd37f4ab38495759a
Hi,
my use case is the following: I am dealing with very large numbers which are represented as arrays of bytes. I am looking for a library which implements arithmetic operations on such arrays. I could implement these myself, but using a library seems to be the more robust option, especially for multiplication and division. Example: Multiplying the following two values:
uint8_t x1[2] = {0, 30};
uint8_t x2[2] = {0, 30};
would yield
uint8_t result[2] = {3, 132};
Is there a library that implements operations like that? I can't use native integers, because the values could be arbitrarily large.
I just remembered how our substitute math teacher always played this game with us in middle school and we were always able to find some answer. So I'm wondering if there's always an answer or at least with certain constraints? how he could've chosen the numbers, so that there was always a solution.
Example : get the number 22 by adding/subtracting/multiplying/dividing 5,4,3,7 and 9 in any order. Possible answer: >!7+9+4+5-3!<
Update: My question is a little vague, so I want to clarify. Judging from my memory I think the numbers were unique and always within [1,100]. gmc98765 delivered the following counter example :
> If you're asking whether any 5 distinct numbers can generate any number in [1,100], the answer is no. There are 5!*44=30720 ways to permute 5 numbers and pick 4 operators, but e.g. in the case of [1,2,3,4,5] that only results in 874 distinct values, of which only 88 are integers and only 46 of those are in [1,100].
Ultimately I'd like to know if we could define the range of operands in relation to the 6th number that allows us to randomly pick numbers within this range and be sure that there is at least one solution.
Hey there Everyone,
Our physics teacher taught us about units and measurements a couple of months ago, and we will soon be having our mid term exams. So, while revising the chapter, I came upon a question which for some reason I never thought of when we first studied the chapter. When I tried getting my doubt cleared by asking the teacher, she naturally didn't help, saying I should have asked the question earlier when the chapter was taught in class. So, I'll be very helpful if any one of you could provide me a solution to this doubt, as it has been there on my mind for quite some time now, and I just can't find any solution to it anywhere on the internet.
β’When dealing with arithmetic operations with significant figures, why do we convey the result of Multiplication and Division by the number of significant figures and the result of Addition and Subtraction on the basis of decimal places? Why is there a difference?
Can't both of them be conveyed on the basis of either significant figures or decimal places? And if not, why is that so?
Please do offer me some guidance on this question. Thank you!
I've been doing some reading on the nuts and bolts of basic maths, following that Wikipedia rabbit hole essentially, and though I now feel more enlightened, I also have a lot more questions. My question for today is: exactly how are the elementary operations defined? I will take you through my thought process, which will reveal the precise nature of my confusion.
So, according to Uncle Wiki, an arithmetic operation like addition is a binary relation, meaning that it is a subset of (AΓB)ΓC, where AΓB is the domain of the operation and C is the codomain; in other words, it takes two elements and spits out a third. The elements of this subset are precisely those which satisfy the definition of the relation. With addition, {(2,4)} is related to {6}, but not {7}.
That's very easy to understand, at least intuitively. My stumbling block comes when I try to make this explicit, by which I mostly mean giving an expression in set-builder notation. All I can think of with that is something like {(a,b,c) ∈ ℕΓℕΓℕ | a+b = c}.
Do you see the problem? In defining addition this way, it was necessary for me to use another, unjustified definition of addition. It seems very circular. I would really like to know how addition (and the other operations) are defined from "first principles", if that makes any sense. I want to see it broken down into its most elementary parts and put back together. Can you help me with that?
Bonus question: the algebraic properties of an operation β commutativity, associativity, etc β are these conditions that we impose arbitrarily, or are they properties guaranteed by the definition of the operations themselves/axioms?
I'm a middle school literature teacher but I studied math. This week I found my students playing an interesting game: they would have a classmate give them five random(ish) 1-digit numbers and a 2-digit number. Then they would try to arrange the five 1-digit numbers using only *, /, +, -, ^, and () in a way that made them equal the 2-digit number. To give you an example of one that they thought was impossible until I helped them:
Given the numbers 2, 3, 5, 6, 7, and 57, you can create the equation 3*(7^2-(5*6))=57.
The natural question to ask is: is there a solution for any set of numbers? If not, is there a counter-example? How could we prove that there is a solution for every set of numbers, and, if there isn't, how could we prove that the counter-example was thorough (i.e. we had tried every possible combination)?
P.S. I don't post here often so sorry if there's some markup that I should have used but didn't.
EDIT: Sorry for not being clear. You are given five 1-digit numbers, you must use each number exactly once.
Example:
function f(x) x/-2 end
f(true) -0.5
Hi,
I need a little help with this R project I'm working on, I have a matrix with 253 columns and 1000 rows, I am trying to create perhaps a for loop or another repeatable function whereby I can subtract the 253rd value of each row from the first, i.e. if the matrix is defined M, the operation I'm attempting is: M[1]-M[253], for all 1000 rows, and then storing these 1000 values in a single row vector. Is it possible to create a loop for this? I can't quite get a grasp on how the for loop would look like. Thanks for any help in advance
(define (perform-op m n opt)
(cond
((eqv? opt #\+)(+ m n))
((eqv? opt #\-)(- m n))
)
)
This is a snippet of the function. m and n are integers, while opt is the operator (which is + or - in this case). Is this right?
I know everything is an object in ruby and integer class has a method (:+) to add. But how does ruby understand to call 1.+2 . I tried reading about grammar and tried my very best to make sense of parse.y and numeric.c in ruby. But couldn't get a clear picture. Sorry if this question is stupid.
After Excel import the BTC. the excel cell shows "$36000" and I want to multiply it with my total BTC amount. If I type a formula (such as =A1*0.02) it gives the error #VALUE!
How can I convert $36000 to a number like 36000 so that arithmetic operations can be done with it?
Thanks in advance for help.
So I have a dictionary that goes on as follows:
{'01.txt': [1, 2], '02.txt': [1, 1], '03.txt': [1, 1], '04.txt': [1, 1], '05.txt': [5, 0], '06.txt': [5, 0], '07.txt': [3, 0], '08.txt': [4, 0], '09.txt': [4, 0], '10.txt': [4, 0], '11.txt': [2, 3], '12.txt': [4, 3], '13.txt': [4, 3], '14.txt': [4, 3], '15.txt': [3, 3], '16.txt': [5, 3], '17.txt': [4, 3], '18.txt': [4, 2], '19.txt': [2, 1], '20.txt': [2, 1], '21.txt': [2, 3], '22.txt': [2, 3], '23.txt': [4, 0]}
Can you tell me how I can do arithmetic operations with values associated with each key?
For example, I will need to add up 1 and 2 (=3), then subtract 2 from 1 (=-1), then divide -1 by 3?
I need a code that does this for all values associated with these 23 keys.
I have recently stumbled upon two commands that can allow one to increment and decrement a selected number (even as a string), I was so blown away that I could not even fathom what had just happened, I even thought I changed it explicitly by replacing the existing numbers in text.
The commands are: Ctrl-A (increment a number) Ctrl-X (decrement a number)
I do have a question, is there any other commands that can be performed to perhaps allow for arithmetic to occur , such as performing multiplication of itself ? (or any arithmetic really)
Never saw this DC message before the update, and now I've gotten kicked out 3 times in 15 minutes. Wtf does that even mean? Anyone know what causes it?
Just firstly.
I wanted to create a very simple Windows Application that could change settings inside an Ini file. I got some help with how to set up the code for changing things like 0 / 1 and saving them out to the file again. And I'm sort of ham-fisting my way through the rest of it like Combo boxes and trackbars.
This error just highlights part of the FloatTrackBar that seems to deal with precision of the trackbar I guess?
This is where is stops when I try to run the program:
Public Overloads Property LargeChange As Single
Get
Return MyBase.LargeChange * _precision
End Get
Set(ByVal value As Single)
MyBase.LargeChange = CInt((value / _precision))
End Set
End Property
I don't really know how to find where it's having an issue with the Arithmetic Operation.
But with just trying to look around the interface for clues, I noticed that directly above this code in small writing it says "2 References" so mousing over that it shows me the 2 trackbars that I have in the project, and reads out a value for each one.
603: Me.tbGrastDist.LargeChange = 5.0E+7!
616: Me.tbGamma.LargeChange = 30!
So I'm guessing the issue is with the top one, as that's 50,000,000 which simply isn't a number that should be there.
Going back to the code I have that deals with that particular TrackBar,
This is the part that reads what is in the current *.CFG file:
'Read Grass Dist
val = GetValue("rescale_target =")
Dim GrassDistval = Decimal.Parse(val)
tbGrassDist.Value = GrassDistval
lblGrassDist.Text = tbGrassDist.Value.ToString("0.0")
and this is the part that writes it back to the file:
'Grass Dist
oldval = GetValue("grass_distance =")
newval = tbGrassDist.Value.ToString("0.0")
SetValue("grass_distance =", newval, oldval)
And I think this is the part that determines the min and max of the TrackBar
tbGrassDist.Maximum = 100.0
tbGrassDist.Minimum = 0.0
tbGrassDist.Value = 100.0
lblGrassDist.Text = tbGrassDist.Value.ToString("0.0")
Now, for reference, the CFG file that it's opening has this line in it.
grass_distance = 0.000
I don't know where to check next, as all of that looks fine to me and I can't see why it would result in a readout of 50,000,000.
Can anyone point me in the right directi
... keep reading on reddit β‘I keep crashing to nexus all the time and it's make the game un fucking playable. Anyone else having this issue?
Hi, I'm C# Backend Developer, i'm writing a simple nodejs app, to try to learn a little about node and the features of javascript. The problem is this:
I want to apply an arithmetic operation on this objects:
VES: {
avg_12h: "1364890388.73",
volume_btc: "96.37428077",
avg_24h: "1347573740.29",
avg_1h: "1365254384.48",
rates: {
last: "1365001365.00"
},
avg_6h: "1362608857.66"
},
ARS: {
avg_12h: "754840.92",
volume_btc: "10.19222191",
avg_24h: "748593.53",
avg_1h: "793295.18",
rates: {
last: "793295.18"
},
avg_6h: "779944.22"
}
With this object:
USD: {
avg_12h: "7289.71",
volume_btc: "94.21345499",
avg_24h: "7475.44",
avg_1h: "4429.60",
rates: {
last: "7735.67"
},
avg_6h: "6678.21"
}
Could be multiply or divide. I almost sure this can be done with reduce but sincerely i don't know how?
this is my code:
app.get("/currency/convert", function (req, res) {
const avg = cacheManager.get("avg");
let usdBtc = Object.keys(avg).filter(key => ["USD"].includes(key))
.reduce((obj, key) => {
return {
...obj,
[key]: avg[key]
};
}, {});
let convert = Object.keys(avg).filter(key => ["ARS", "VES"].includes(key))
.reduce((obj, key) => {
console.log(obj)
return {
...obj,
[key]: avg[key]
};
}, {});
res.send(convert);
});
Sorry if i'm not clear enough. Excuse for my english.
Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.