Hi, I have f.eks
X = 01001001 and Y = 10101010
If I want to add them together how do I do that? They are "Two's Complement"...
I have tried a lots of things but I am not quite sure I am getting the right answer since there seems to be different type of rules.
Just want to make sure it is correct:
1. Add them as they are do not convert...
Hi, I'm sure this is a very simple question! I have a Java method in which I'm summing a set of numbers. However, I want any negatives numbers to be treated as positives. So (1)+(2)+(1)+(-1) should equal 5. I'm sure there is very easy way of doing this - I just don't know how!! Any tips would be much appreciated.
...
In a TC++ compiler, the binary representation of 5 is (00000000000000101).
I know that negative numbers are stored as 2's complement, thus -5 in binary is (111111111111011). The most significant bit (sign bit) is 1 which tells that it is a negative number.
So how does the compiler know that it is -5? If we interpret the binary value gi...
Hi. I have an owner-drawn listbox control in my project. The problem is that sometimes the DrawItemEventArgs argument passed to my DrawItem event-handler has an Index property of "-1". It seems that this only happens when I scroll through the list box and then try to close my application; To avoid getting an exception I did something ver...
Hello there, I'm really stuck here...
I have a site layout with a central layout (it's about 922px width, centered on the page)... I have a little logo that is to the top left of this, but it sticks about 10 pixels to the left of the central design. If you can imagine, it sort of sticks out to the left of the design...
Now, I was told ...
So I thought that negative numbers, when mod'ed should be put into positive space... I cant get this to happen in objective-c
I expect this:
-1 % 3 = 2
0 % 3 = 0
1 % 3 = 1
2 % 3 = 2
But get this
-1 % 3 = -1
0 % 3 = 0
1 % 3 = 1
2 % 3 = 2
Why is this and is there a workaround?
...
in my output of a grid
i calculate a TimeSpan and take its TotalHours ex. (Eval("WorkedHours") - Eval("BadgedHours")).TotalHours
goal is to show this TotalHours as : 39:44 so. First value 7.5 to 07:30
no problem.. but if its negative!
I can create a TimeSpan object from Hours with TimeSpan.FromHours( (Eval("WorkedHours") - Eval("Ba...
We're using SQL Server Standard Edition 8.00.760 (SP3) on a Small Business Server 2003 platform.
While tracking down an inexplainable System.Data.DBConcurrencyException for a Strongly Typed DataSet, I discovered the following problem:
Given is this table:
CREATE TABLE [dbo].[Auszahlung](
[auszahlungid] [int] IDENTITY(1,1) NOT NULL,...
In Java, I just read a file into a ByteBuffer. When I started checking to make sure that the ByteBuffer contained the right bytes, I noticed that it had mostly the correct start and end bytes, except for the 3rd byte, it has -117 instead of what emacs says should be 139 (8b in hexl-mode). What gives? Does this have something to do with B...
I am trying randomly generate a positive or negative number and rather then worry about the bigger range I am hoping to randomly generate either 1 or -1 to just multiply by my other random number.
I know this can be done with a longer rule of generating 0 or 1 and then checking return and using that to either multiply by 1 or -1.
Hop...
I have a lot of files with data to convert to percentages using basic math functions:
<param id="1" name="otb" value="0.160"/>
<param id="2" name="blm" value="-0.210"/>
<param id="3" name="mep" value="-0.010"/>
<param id="4" name="plc" value="-0.100"/>
Each id get's it's own equation:
(n-(-.3))/2.3*100
(n-(-.8))/3.3*100
(n-(-.5))/1....
I have a C code in which I do the following
int nPosVal = +0xFFFF; // + Added for ease of understanding
int nNegVal = -0xFFFF; // - Added for valid reason
Now when I try the following
printf ("%d %d", nPosVal >> 1, nNegVal >> 1);
I get
32767 -32768
Q-1: Is this expected?
I am able to think something like
65535 >> 1 = (int)...
this seems a bit nutty:
var r:Rectangle = new Rectangle();
trace("initial rect: " + r); // (x=0, y=0, w=0, h=0)
var p:Point = new Point(-5, -3); // (x=-5, y=-3)
trace("point: " + p);
r.inflatePoint(p);
trace("inflated rect: " + r); // (x=5, y=3, w=-10, h=-6)
i would expect the result to be (x=-5, y=-3, width=5, heigh...
I am fairly new to Haskell but do get most of the basics. However there is one thing that I just cannot figure out. Consider my example below:
example :: Int -> Int
example (n+1) = .....
The (n+1) part of this example somehow prevents the input of negative numbers but I cannot understand how. For example.. If the input were (-5) I wou...
Hello!
I have a gradient that changes its colors, I want the text inside it should always be visible.
I rather doing it dynamically if there is any out-the-box resource; I want a 'magic brush' that negates the color.
Any experiments?
...
Hey guys,
Basically I've been trying to make a working hours calculator and I've run into a problem. When the start time's value is greater than the finish time (eg. start is 23 and finish is 19), the result comes up as a negative. So what I want it to do in that scenario is to then multiply the negative number by -1 to make it positi...
I'm trying to find more about history of java.io.FileInputStream.skip(n) operation when n is negative. According to InputStream documentation:
If n is negative, no bytes are skipped.
It seems that implementation of FileInputStream from Sun used to throw IOException instead, which is now also documented in Javadoc:
If n is negat...
hello everyone. Thank you for your help in advance. I am a student in a concepts of programming class. The lab is run by a TA and today in lab he gave us a real simple little program to build. It was one where it would multiply by addition. Anyway, he had us use absolute to avoid breaking the prog with negatives. I whipped it up real qui...
For a very simple profiling I use microtime() like this:
$now = microtime();
for (...) {
// do something
echo microtime() - $now;
$now = microtime();
}
Now, the output of the echo line seems completely random, that is, I expected fluctuations, but I don't expected negative numbers showing up.
However, a typical result con...
Hi Guys
Is there a way to apply negative tax amount into a tax field (e.g. quote product) in Microsoft Dynamics CRM 4?
...