473,320 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Change the sign of an integer

Hi,
How do I change a positiv integer to a negative value ?
tnx
Totto
Nov 20 '05 #1
2 5693
On 2004-02-19, Totto <ta*********@norcon.no> wrote:
Hi,
How do I change a positiv integer to a negative value ?
tnx
Totto


Dim value As Integer = Math.Abs(MyInt) * -1

value will always be negative...
--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
Computer programs expand so as to fill the core available.
Nov 20 '05 #2
Totto,
In addition to multiple by -1 as Tom showed, you can subtract from 0.

Dim value As Integer = 0 - Math.Abs(MyInt)

I'm sure there are one or two other methods you could use.

Hope this helps
Jay

"Totto" <ta*********@norcon.no> wrote in message
news:OZ**************@tk2msftngp13.phx.gbl...
Hi,
How do I change a positiv integer to a negative value ?
tnx
Totto

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: Claude Gagnon | last post by:
Hi, How can we compare sign of numbers in C++ ? Bye, Claude
13
by: Jeff | last post by:
Hi! I'm trying to update a number in a document with the following code. It displays a number, a div block with a minus sign and a div block with a plus sign. When I click the plus sign I want...
2
by: Isz | last post by:
Hi Group: I would like to know if it is possible to change the name of an attribute to something else. My setup is like this: I have serveral SQL tables that I nest and join so that it all...
5
by: MLH | last post by:
Suppose I have a sentence like "One Two Three Four" and I want it to say "One+Two+Three+Four". Taking into account that there might be more than a single space separating the words sometimes. ...
10
by: Sona | last post by:
Hi, Could someone please explain what sign-extension means? If I have a hex number 0x55, how does this get sign-extended? Can a sign-extended counterpart be equal to -91? In a program I'm...
2
by: Andreas Klemt | last post by:
Hello, how can I change the sign of an Integer Value like Abs?(100) -> -100 Thanks, Andreas
0
by: Emil Georgiev | last post by:
Hell I have a Web Custom Control project in ASP.NET. I'm using a subclassing technique to add functionality in HyperLink web server control. I want to create a property "BrowserWindow" of my...
6
by: Jason Heyes | last post by:
Does a function exist in the standard library to compute the sign of an integer? Example: int sign(int v) { return v > 0 ? 1 : (v < 0 ? -1 : 0); } Thanks.
4
by: ComaGrrrl | last post by:
I'm trying to "Write a function itob(n, s, b) that converts the integer n into a base b character represeantation in the string s. In particular, itob(n, s, 16) formats n as a hexadecimal integre...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.