Arithmetic operation in php on a character string

I have a strange issue. I do this: $expdatek = explode(".",$datumk); $expdated = explode(".",$datumd); if($expdatek[2] == $expdated[2]){ $monthk = intval(ltrim($expdatek[1], '0')); $monthd = intval(ltrim($expdated[1], '0')); $interval

Combine Set, Clear and Toggle into a C line

I am trying to combine three bit operations in one line of C. For a 8 bit char, I have to set bits 2, 4, 6; clear bits 1, 3, 7 and toggle bit 0 and 5 all in one line code of C. I could do these in three line but I cannot combine these. Below is what

Calculate the mode of the Checksum Xbee C # API

I need to calculate a specific checksum for an Xbee Frame. The process is : To calculate the check sum you add all bytes of the packet excluding the frame delimiter 7E and the length (the 2nd and 3rd bytes). 7E 00 0A 01 01 50 01 00 48 65 6C 6C 6F B8

adding or subtracting doubles gives a bad result

if (CIElchOpposite[2] < 180.0) { CIElchOpposite[2] = CIElchOpposite[2] + 180; } else { CIElchOpposite[2] = CIElchOpposite[2] - 180; } For a given CIElchOpposite[2] = 82; the return result is 180 when it should be 262. CIELchOpposite is double []. It

What mathematical operation comes after the exponentiation (^)?

Let's give expressions some names: x+3 = x+1+1+1 // lvl 1 x*3 = x+x+x // lvl 2 x^3 = x*x*x // lvl 3 What would be the mathematical term / real name / topic for lvls after 3? Like: x (lvl 4 operation) 3 = x^x^x x (lvl 5 operation) 3 = x(lvl 4 operatio

Get the full number when you divide two fields

I was trying to round some fields. When I have 59 days, I want to change it to 60. The problem is that when I use this code, the 59 is changed to 30 because the round it is 1. select round(1.9666,0)*30, round(59/30,0)*3' The result of that query is 6

Why does this code always return the size of the zero file?

Why, when I use following code snippet the result is zero regardless of the file size, but when I remove ios::binary in open() it does what it's supposed to do? fstream f1; streampos begin, end;"file1", ios::binary); f1.seekg(0, ios::be

floating point operations with bash

how can I transform the string "620/100" into "6.2" in a bash script The context of my question is about image processing. EXIF data are coding the focal length in fractional format, while I need the corresponding decimal string. Thank

Matrix operations (transpose)

I want to perform matrix operation (for example find the transpose matrix of a given matrix A) I found some libraries to do so, for example Colt:

Python - is it possible to define a variable to an operator?

I'm developing a bunch of functions that have the same basic structure - they take two lists and use a loop to do a particular operation pairwise for the two lists (for example, one will take each element of a list raised to the power represented by

PowerShell more than one operations using pipes

My script looks for all the files in folder1 and checks if this file exist in folder2. if it exists then I want to delete the file from folder2 and move the file from Folder1 to folder3. $folder1 = "D:\folder1" $folder2= "D:\folder2" $

Illegal operation on an empty result set

I'm trying to build a pay desk in a grocery store and my code actually performs what I intend for it to do, but for one thing. After I ask the user to enter how many of an item they want, the product information is gathered and works fine, but when i

java Bit operations & gt; & gt; & gt; shift

Why if int x = -1 // binary: 11111111111111111111111111111111 x = x >>> 31; we have 00000000000000000000000000000001 but if int x = -1 x = x >>> 32; we have 11111111111111111111111111111111 (again -1) but not 0000000000000000000000000000

Can I convert a string to a mathematical operation in Java?

can I convert a string like "3*3+3" to math operation in java??Evaluate it is as JavaScript using ScriptEngine String xyz = "3*3+3"; ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine se = manager.getEngineByName(&qu

Ruby - Timestamp of yesterday at some time

I have the following issue: I want to get the timestamp of yesterday on a specific time. With what I've come up so far is: Time.local("%Y"),"%m"), ("%d")-1), 23, 59, 59).

Stop the current operation in Visual Studio

When using Visual Studio I often encounter situations when the IDE freezes while performing some operation. For instance, this frequently happens when I move next statement pointer (yellow arrow) during the debug session, when I unintentionally press

Help with conditional operation

I have some basic knowledge in PHP, and I actually understand what the code below actualy does, but I need to do a thing a little bit mor complex and I hope you can help me. I am the admin of a sales website, we had some troubles with the programmer

A multiplication of 3D matrix without loop in python

I am looking to do the following operation in python (numpy). Matrix A is M x N x R Matrix B is N x 1 x R Matrix multiply AB = C, where C is a M x 1 x R matrix. Essentially each M x N layer of A (R of them) is matrix multiplied independently by each

Slow performance with the growth in the number of transactions

I have next problem. My code performance depends on number of operation! How can it be? (I use gcc v 4.3.2 under openSuse 11.1) Here is my code: #define N_MAX 1000000 typedef unsigned int uint; double a[N_MAX]; double b[N_MAX]; uint n; int main(){ fo

Why are Red_Black trees better than 2-3 trees?

Apart from red-blacks being easier to implement. All operations (insertion, deletion, lookup) seem to have a time complexity of O(log n), in both trees. Is there a certain difference between these operations that I'm missing? If you google search "re

Prolog: redefinition of the recursive function

Is there a way to "recursively redefine" (don't know the technical term) prolog predicates? Consider these predicates: f(X,Y,A):-A is Y xor X. arity(f,2). now i want to automatically create 2 new predicates f1/2 and f2/1 with the following defin