Questions tagged [operations]
298 questions
1
vote
2 answers
Atomic operation seems slower than Semaphore operations in multithreading shared process
Can you think on any good reason why atomic operations seems slower than semaphores, even though there is a decrease on instructions?
Sample code:
void increment(){
if (strcmp(type, "ATOMIC") == 0) {
for (int i = 0; i < RUN_TIME; ++i)…

Bruno Miguel
- 51
- 5
1
vote
1 answer
Using bitwise operations to implement absolute value
I'm trying to make an int array that takes in doubles from a double array, truncates the values into ints by casting, and then using bitwise operations to get the absolute value of the ints. Here's what I've got so far:
int int_array[20];
int…

Quabs
- 51
- 9
1
vote
0 answers
Pandas calculating frequency in nested groupby
I have a huge data with the following columns
|CategoryX|CategoryY|Time
|X a |Y a |2017-10-01 17:30:00
|X a |Y b |2017-10-09 12:30:00
|X b |Y a |2017-10-03 18:30:00
|X b |Y a |2017-10-05 16:30:00
|X b |Y…

user3064676
- 11
- 2
1
vote
1 answer
Calculating the quotient between two files and writing it into another file
Using Python, I have two large (equally long) files in which the numbers are divided by spaces:
0.11158E-13 0.11195E-13 0.11233E-13 ... # file1
0.11010E-13 0.11070E-13 0.11117E-13 ... # file2
There are differences in the values and I would like to …

Robert
- 57
- 8
1
vote
1 answer
Floating point IEEE guarantees
I would like to know, for the following cases, if the IEEE standard guarantees every possible case (excluding NaN and infinities) using any cpu adhering to the standard:
Commutativity: x # y = y # x
Associativity: (x # y) # z = x # (y # z)
x - x =…

ZeroZ30o
- 375
- 2
- 18
1
vote
1 answer
Select multiple entries in SQLite where multiple rows need to match the same condition (including AND, OR and NOT)
I have a question regarding selecting in SQLite. I have given entries in a DB, where i need to select all rows which match my criterion. These criterion can be combined with AND, OR or NOT.
For example, I have
id | image | tag
…

Ramon
- 63
- 6
1
vote
1 answer
Prediction with lm
I have the following data frame:
lm mean resids sd resids resid 1 resid 2 resid 3 intercept beta
1 0.000000e+00 6.2806844 -3.6261548 7.2523096 -3.6261548 103.62615 24.989340
2 -2.960595e-16…
user7375046
1
vote
2 answers
elementwise boolean testing in a matrix
I need to test a boolean in an array, and based on the answer, apply an elementwise operation on a matrix. I seem to be getting the boolean answer for the ROW and not for the individual element itself. how do i test and get the answer for each…

kinda.anonymous
- 43
- 5
1
vote
3 answers
Why the result is 8?
Today I had a job interview on JS and one of the questions was
What is the value of a
var a = (3,5 - 1) * 2;
Hmm I assumed its 8 (the chrome dev console also gives it 8) but I don't know why it is eight. Why the 3 is omitted? I mean of course you…

Nicholas
- 3,529
- 2
- 23
- 31
1
vote
2 answers
Why does this code crash when run?
New to C and going to be learning it so I can develop strong fundamentals so I decided to sign up here. Thanks for the help in advanced. What's wrong with my code — it crashes on the final printf() line?
#include
main(int argc, char…

Charles Mullen
- 7
- 4
1
vote
2 answers
currency extraction jQuery
Clicking on any currency (e.g. $44,721.90) should extract by itself and return $0.
Currently is returning $NaN. I'm using ES6 Intl.NumberFormat("en-US") to give currency format to the numbers.
var name1 = {
name: "John",
money:…

Syden
- 8,425
- 5
- 26
- 45
1
vote
2 answers
Counting primitive operations, Big O Notation
Say I have a int variable called count, I was wondering how many primitive operations are int the statement:
count++;
Would it be 3? Because if you write it out in a different form, such as:
count = count + 1;
It has 1 read, 1 operation, and 1…

ANewGalaxy
- 31
- 7
1
vote
1 answer
Search and Compare Columns to Create New Columns (Teradata SQL)
I have a dataset with Sale event history, and i need to create a column to show if the sale is still active. My dataset looks like this:
item | original_price | sale1 | sale2 | sale3 |…

pyll
- 1,688
- 1
- 26
- 44
1
vote
1 answer
Operations on adjacent elements in a vector
I have a binary vector, if I find a 0 in the vector I want to make the adjacent elements 0 if they are not already.
For example if input = [1 1 0 1 1] I want to get output = [1 0 0 0 1]
I tried the following but it's messy and surely there is a…

Hefaestion
- 203
- 1
- 8
1
vote
2 answers
What's the most efficient way of operating with fields in MySQL?
I have the following query:
SELECT DATE(utimestamp) as utimestamp, name, data*2000000 from tData
where utimestamp BETWEEN '2016-01-01 00:00:00' AND '2016-04-16 00:00:00'
AND name = 'Valor2' and data>20
group by YEAR(utimestamp), MONTH(utimestamp),…

Didina Deen
- 195
- 2
- 17