I can't seem to do it ![]()
-
-
i can do it like this
(myInt) - (myInt *2)
is there a function in VB? -
leeappdalecom wrote:i can do it like this
(myInt) - (myInt *2)
is there a function in VB?
A simpler way would be (myInt * -1).
I had a look around the Math class, but couldn't find anything specific. -
I'm guessing, since I don't use Vb.Net, but I can't believe that you can't do this:
MyInt = -MyInt
-
Cool cheers guys, you would have though the Math class would have a function to do this, I'm a programmer I dont want to have to do maths manually thats what the computers for lol
-
leeappdalecom wrote:Cool cheers guys, you would have though the Math class would have a function to do this, I'm a programmer I dont want to have to do maths manually thats what the computers for lol
the "standard" method is x*-1 as another post said.
that bit of code is very small and if you built a function for it then the perfomance would suck... pushing and poping the stack etc...
to do what is generaly about 2 or 3 machine level instructions.
also the compiler can generate code from that expression for all kinds of data, byte, short int, long int, float, decimal and whatever.
if you want the value "X" to have the inverse directly then you code:
x = x*-1
where x is any valid data type such as an int.
you can also use a binary operator if you want to get cute, invert the bits of an int and you have the same effect as I recall, been a while since I did that ... MASM for DOS back then. -
figuerres wrote:
you can also use a binary operator if you want to get cute, invert the bits of an int and you have the same effect as I recall, been a while since I did that ... MASM for DOS back then.
Invert the bits then add 1 (two's complement arithmetic)
Couldn't you use x = 0 - x, though? -
errr.... has it been a long day or somthing?
Dim myInt As Integer = 10
Dim reversedInt As Integer
reversedInt = -myint
-
That's what I said Tensor.
Can't believe this. It's the dumbest thread I've ever seen on here. And there've been some pretty dumb threads.
A function in System.Math to calculate the negative of an integer? This has got to be trolling.
Next you'll be wanting to see
result = Math.Multiply(Math.Subtract(Math.Add(a, b), c), d);
instead of:
result = ((a + b) - c) * d;
Who's going to submit this thread to the daily wtf then? -
lol chill out
-
You could use a SQL Server database that has a precalculated table with all the possible integers and their negative. Then you could build an ASP.NET webservice using SOAP to access the database. Then you can consume this web service in your application. How's that for a solution?
-
leeappdalecom wrote:Cool cheers guys, you would have though the Math class would have a function to do this, I'm a programmer I dont want to have to do maths manually thats what the computers for lol
The math function is...
f(x) = x * -1
-
TommyCarlier wrote:You could use a SQL Server database that has a precalculated table with all the possible integers and their negative. Then you could build an ASP.NET webservice using SOAP to access the database. Then you can consume this web service in your application. How's that for a solution?
It needs more javascript. -
TommyCarlier wrote:You could use a SQL Server database that has a precalculated table with all the possible integers and their negative. Then you could build an ASP.NET webservice using SOAP to access the database. Then you can consume this web service in your application. How's that for a solution?
Why not just fiddle with the actual bits?
-
Larsenal wrote:Why not just fiddle with the actual bits?
That's not "Enterprise" enough. I still say it needs more javascript. Maybe some BizTalk too. Don't you read the daily WTF?
-
Sven Groot wrote:
That's not "Enterprise" enough. I still say it needs more javascript. Maybe some BizTalk too. Don't you read the daily WTF?
Don't forget to use XML to store everything.
Mmmmm, enterprisey </homer> -
AndyC wrote:

Sven Groot wrote:
That's not "Enterprise" enough. I still say it needs more javascript. Maybe some BizTalk too. Don't you read the daily WTF?
Don't forget to use XML to store everything.
Of course, you have to store the XML as a string in your database. And then generate HTML from it in an sproc. If you're using Oracle, even better! Doing it in PL/SQL should be even more fun than T-SQL. -
Don't forget serialization and a mention of SOA.
Thread Closed
This thread is kinda stale and has been closed but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.