Compression of memory locations when using absolute memory addressing in 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

πŸ‘︎ 11
πŸ’¬︎
πŸ‘€︎ u/ConlangBabble
πŸ“…︎ Jan 02 2022
🚨︎ report
Can dolphins really do arithmetic operations?

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?

πŸ‘︎ 20
πŸ’¬︎
πŸ‘€︎ u/duck_duckone
πŸ“…︎ Oct 17 2021
🚨︎ report
Arithmetic int64 operations highly unoptimized in Matlab?

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

πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/22Maxx
πŸ“…︎ Sep 19 2021
🚨︎ report
Number of arithmetic operations needed to solve the system of linear equations using Cramer's rule?

https://preview.redd.it/qegoa3tb9tx71.png?width=686&format=png&auto=webp&s=f81f6a76c454053d6b352a2bd37f4ab38495759a

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/-ajf-
πŸ“…︎ Nov 05 2021
🚨︎ report
Library for arithmetic operations on integers represented by arrays

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.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/b0mb4st1c0
πŸ“…︎ Oct 06 2021
🚨︎ report
Is there always a solution for using arithmetic operations on 5 given numbers to get a 6th number?

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.

πŸ‘︎ 22
πŸ’¬︎
πŸ‘€︎ u/StrangeParsnip
πŸ“…︎ Jul 21 2021
🚨︎ report
[Units and Measurement] Rules of Arithmetic Operations with Significant Figures

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!

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/qwertyiiiiiiii
πŸ“…︎ Sep 16 2021
🚨︎ report
How is addition (and the other elementary arithmetic operations) formally defined?

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) &isin; &#8469;Γ—&#8469;Γ—&#8469; | 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?

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/theblindgeometer
πŸ“…︎ Aug 15 2021
🚨︎ report
Can you make any 2-digit number out of any set of five unique 1-digit numbers using the basic arithmetic operations, exponents, and parentheses?

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.

πŸ‘︎ 30
πŸ’¬︎
πŸ‘€︎ u/kreuelt
πŸ“…︎ Mar 26 2021
🚨︎ report
Is SafeMath redundant at this point with the safety of the latest Solidity versions arithmetic operations? Is it worth the gas cost of using it anymore?
πŸ‘︎ 3
πŸ’¬︎
πŸ“…︎ Aug 01 2021
🚨︎ report
Why is Bool a subtype of Integer? Is allowing arithmetic operations on values of type Bool not confusing?

Example:

function f(x) x/-2 end

f(true) -0.5

πŸ‘︎ 16
πŸ’¬︎
πŸ‘€︎ u/No_Judgment478
πŸ“…︎ Jun 08 2021
🚨︎ report
How to loop an arithmetic matrix operation in R

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

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/DennoLDBC
πŸ“…︎ May 22 2021
🚨︎ report
Perform arithmetic operation based on 2 numbers and 1 operator
(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?

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/qeeixxo
πŸ“…︎ Apr 14 2021
🚨︎ report
How does ruby understand arithmetic operations like (1 + 2) ?

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.

πŸ‘︎ 8
πŸ’¬︎
πŸ“…︎ Apr 09 2021
🚨︎ report
Are there other operations beyond ones in arithmetic? (+, -, /, Β·, exp., tetration, etc...)
πŸ‘︎ 51
πŸ’¬︎
πŸ‘€︎ u/Mah_Legzz
πŸ“…︎ Nov 26 2020
🚨︎ report
I imported CoinMarketCap live rate of BTC into Excel but I can't multiply it with my total BTC amount. How to do arithmetic operation on imported currency values?

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.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Styx1213
πŸ“…︎ May 29 2021
🚨︎ report
Arithmetic operations between same-key values in a dictionary

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.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Endleofon
πŸ“…︎ Apr 13 2021
🚨︎ report
El Lissitzky, 4 arithmetic operations. 1928, Reprint. Koln. 1976
πŸ‘︎ 21
πŸ’¬︎
πŸ“…︎ Apr 20 2021
🚨︎ report
Just a normal easy and simple as simple program of normal arithmetic operations. v.redd.it/vl4967z47lm61
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/ytohiwipieown31
πŸ“…︎ Mar 12 2021
🚨︎ report
When int variables do arithmetic operations, why do they truncate after every step instead of the very last step, as it creates large errors?
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/Llsangerman
πŸ“…︎ Dec 07 2020
🚨︎ report
Oops...Arithmetic operation overflow
πŸ‘︎ 178
πŸ’¬︎
πŸ‘€︎ u/VitrixGames
πŸ“…︎ Jul 12 2020
🚨︎ report
Building a Complete System of Arithmetic & Algebra & Eventually a 'Trigonometry' for the Hyperbolic Geometry of the PoincarΓ© Disc - with a Cute Workaround for the Not-Group-Forming-ness of the Operations in their 'Raw' Form
πŸ‘︎ 13
πŸ’¬︎
πŸ‘€︎ u/SassyCoburgGoth
πŸ“…︎ Jan 14 2021
🚨︎ report
Building a Complete System of Arithmetic & Algebra & Eventually a 'Trigonometry' for the Hyperbolic Geometry of the PoincarΓ© Disc - with a Cute Workaround for the Not-Group-Forming-ness of the Operations in their 'Raw' Form
πŸ‘︎ 29
πŸ’¬︎
πŸ‘€︎ u/SassyCoburgGoth
πŸ“…︎ Jan 14 2021
🚨︎ report
Arithmetic operation upon strings and numbers

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)

πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/justinjoseph7
πŸ“…︎ Nov 08 2020
🚨︎ report
Arithmetic Operation Overflow?

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?

πŸ‘︎ 33
πŸ’¬︎
πŸ‘€︎ u/Hesterboyz
πŸ“…︎ Jul 02 2020
🚨︎ report
System.OverflowException:'Arithmetic operation resulted in an overflow.' I don't know what I'm doing! haha!

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 ➑

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/phunkaeg
πŸ“…︎ Nov 06 2020
🚨︎ report
TIL The basic operations of arithmetic are presumed in various Bible passages. Fractions are mentioned in Leviticus, and inequalities are either mentioned or implied in Matthew and Genesis. There is reference to the magnitude of pi in Kings trinityfoundation.org/jou…
πŸ‘︎ 71
πŸ’¬︎
πŸ‘€︎ u/vannybros
πŸ“…︎ Dec 17 2019
🚨︎ report
The people who insist that school exams are "too easy and nothing compared to the ones back in my day!" seem to be roughly the same group of people failing the arithmetic challenges on Facebook because they don't understand the order of operations.
πŸ‘︎ 2k
πŸ’¬︎
πŸ‘€︎ u/InsertDisk22
πŸ“…︎ Dec 17 2016
🚨︎ report
Arithmetic Operation Overflow every 10 minutes?

I keep crashing to nexus all the time and it's make the game un fucking playable. Anyone else having this issue?

πŸ‘︎ 17
πŸ’¬︎
πŸ‘€︎ u/Nagasuma
πŸ“…︎ Jul 03 2020
🚨︎ report
Arithmetic operation on objects by the values of another object

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 =&gt; ["USD"].includes(key))
  .reduce((obj, key) =&gt; {
    return {
      ...obj,
      [key]: avg[key]
    };
  }, {});

  let convert = Object.keys(avg).filter(key =&gt; ["ARS", "VES"].includes(key))
  .reduce((obj, key) =&gt; {
    console.log(obj)
    return {
      ...obj,
      [key]: avg[key]
    };
  }, {});

  res.send(convert);
});  

Sorry if i'm not clear enough. Excuse for my english.

πŸ‘︎ 7
πŸ’¬︎
πŸ‘€︎ u/pachecogeorge
πŸ“…︎ Apr 23 2020
🚨︎ report

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.