473,406 Members | 2,956 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,406 software developers and data experts.

absolute value of a integer

Is there a way to get an absoulte value of a 32bit signed integer? I noticed
Math.abs is an 8-bit integer, but i need the absoulte value of a larger
number. thanks!
Nov 21 '05 #1
4 6273
The math.abs function is overloaded. You can pass in any of the following
types and a number OF THAT TYPE is returned
long
short
single
double
sbyte
integer
decimal

Overloading allows the compiler to chose the correct function based upon the
type of the value passed in.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Brian Henry" <no****@nospam.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Is there a way to get an absoulte value of a 32bit signed integer? I noticed Math.abs is an 8-bit integer, but i need the absoulte value of a larger
number. thanks!

Nov 21 '05 #2
"Brian Henry" <no****@nospam.com> schrieb:
Is there a way to get an absoulte value of a 32bit signed integer? I
noticed Math.abs is an 8-bit integer, but i need the absoulte value of a
larger number.


'Math.Abs' is overloaded, and there is one overload that takes an 'Int32'
and returns an 'Int32'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
thanks didin't notice that... was relying on intellisense too much for what
it returned and forgot about overloading
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:eB******************@tk2msftngp13.phx.gbl...
"Brian Henry" <no****@nospam.com> schrieb:
Is there a way to get an absoulte value of a 32bit signed integer? I
noticed Math.abs is an 8-bit integer, but i need the absoulte value of a
larger number.


'Math.Abs' is overloaded, and there is one overload that takes an 'Int32'
and returns an 'Int32'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #4
"Brian Henry" <no****@nospam.com> schrieb:
thanks didin't notice that... was relying on intellisense too much for
what it returned and forgot about overloading


If you are using VS.NET, there is a small arrow shown in the intellisense
tooltip if overloads exist. You can use the up and down keys to switch
between the overloaded versions.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5

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

Similar topics

2
by: Joachim Bauer | last post by:
I'm using the code below to display a menu that opens when the mouse goes over the main menu item (try it in your browser to understand the behaviour). It uses "position:absolute" and a switch...
4
by: Pf | last post by:
A piece of html code: <table> <tr> <td> <input type="text" name="myInput" onclick="myFunction(this)"> <td> </tr> </table>
34
by: Christopher Benson-Manica | last post by:
I'm trying to compute the absolute value of an integer using only bitwise operators... int x; sscanf( "%d", &x ); printf( "%d\n", (x^((~((x>>31)&1))+1)) + ((x>>31)&1) ); That works, but it...
4
by: Bill Nguyen | last post by:
How do I get the absolute value of an expression in VB.NET? The new ABS function looks scary to me! Thanks Bill
26
by: Clodoaldo Pinto | last post by:
I'm starting a programming tutorial for absolute beginners using Python and I would like your opinions. http://programming-crash-course.com Regards, Clodoaldo Pinto
10
by: JDT | last post by:
Hi, Can someone provide me an example that uses std::max_element() (probablly the predicate version) to return the max "absolute" integer in a vector? Your help is much appreciated. Tony ...
4
by: Bails | last post by:
Hi Im an absolute beginner in programming and am using VB.Net Express. To start my larning I decided to do a "Real World" app instead of "hello world" and am creating a Poker Countdown clock. ...
1
by: bluepiper | last post by:
Im using VB6. On rowcolchange event of may datagrid, im using the Frame caption to get the selected data. The problem is when I select the data on the grid. Its not showing the absolute position,...
7
by: Chad | last post by:
I really don't understand how something like.. #define abs(x) (((x) < 0) ? -(x) : (x)) could cause a possible overflow.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.