473,386 Members | 1,830 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,386 software developers and data experts.

Is value positive or negative in field

I want to find out if a specific value in a field is a Negative value or a Positive values. Examples of values: -5, 6, -44.65, 1247, -1.9 Is there a function in MS Access or code to determine this....once I know if positive or negative then I can apply correct formula to this...thanks Rosemary
Jun 21 '07 #1
2 18055
nico5038
3,080 Expert 2GB
What by comparing the field with zero like:

IF Field < 0 then
negative
else
positive
endif

Nic;o)
Jun 21 '07 #2
ADezii
8,834 Expert 8TB
I want to find out if a specific value in a field is a Negative value or a Positive values. Examples of values: -5, 6, -44.65, 1247, -1.9 Is there a function in MS Access or code to determine this....once I know if positive or negative then I can apply correct formula to this...thanks Rosemary
Believe it or not, there is a Function designed specifically for this and is called the Sgn() Function. The syntax is Sgn(number) and it returns a Variant(Integer) indicating the Sign of the number. If the number (or expression evaluating to a number) is greater than 0, Sgn(number) returns 1, if it is equal to 0, Sgn(number) returns 0, and if its is less than 0 Sgn(number) returns -1. A couple of examples will illustrate this Function:

Expand|Select|Wrap|Line Numbers
  1. Dim MyVar1, MyVar2, MyVar3, MySign
  2. MyVar1 = 12: MyVar2 = -2.4: MyVar3 = 0
  3.  
  4. MySign = Sgn(MyVar1)    ' Returns 1.
  5. MySign = Sgn(MyVar2)    ' Returns -1.
  6. MySign = Sgn(MyVar3)    ' Returns 0.
Jun 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: cylin | last post by:
Hi all, If I have a variable and it's just have 22 bits, and I must set this variable unsigned integer. This 2's complement value maybe is negative. For example: A= 11 1111 1111 1110 ...
7
by: pj | last post by:
Why does M$ Query Analyzer display all numbers as positive, no matter whether they are truly positive or negative ? I am having to cast each column to varchar to find out if there are any...
2
by: hyphen | last post by:
I have set up two date fields in a table: 1stpromisedDate and CurentPromisedDate The first field is to record the 1st promised delivery date of a supplier and the second is to record the...
19
by: Harshan | last post by:
The range of signed int is - 2^15 to + (2^15 )-1 (-32768 to 32767) Why the one less at positive Range ? (compared to the negative side..!) I came to know that it uses 2's compliment...
16
by: TTroy | last post by:
Hello, I'm relatively new to C and have gone through more than 4 books on it. None mentioned anything about integral promotion, arithmetic conversion, value preserving and unsigned preserving. ...
4
by: bardo | last post by:
Does anyone know if there is a easy way to change a negitive int value into a positive int value. int a = -105 > change this to 105. With other words is there a command to change to neg...
0
by: Bill Littman | last post by:
We are using a DB2 7.2 system. On the DB2 Control Center of a server, we are viewing the details of the tablespaces. The "percentage used" column is showing a negative value(-69) for one of the...
29
by: garyusenet | last post by:
I'm trying to investigate the maximum size of different variable types. I'm using INT as my starting variable for exploration. I know that the maximum number that the int variable can take is:...
1
by: vikastcser | last post by:
Hi All , I have a table where four rows are there and each row has two tds.one td is for label and two image icons and other td is used for keeping numeric values. I am able to accomodate digits...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.