|
-
May 17th, 2008, 02:51 PM
#1
Thread Starter
Frenzied Member
How to get absolute value for floating number
I have float number 2.11.
How do I get the absolute value for this number?
Code:
Dim av As String
av = Abs(2.11) <= 0.0005
-
May 17th, 2008, 03:07 PM
#2
Re: How to get absolute value for floating number
I'm a bit confused by what you mean, my understanding of an absolute value is just the value without sign i.e. AbsoluteValue = Abs(number)
What do you mean?
-
May 17th, 2008, 03:20 PM
#3
Thread Starter
Frenzied Member
Re: How to get absolute value for floating number
I have floating number 2.11 . In the field name it showed 2.11.. But absolutely it mybe 2.11324.. So I want to get the value after 2.11
Abs(2.11 <= 0.0005)
-
May 18th, 2008, 02:02 AM
#4
Re: How to get absolute value for floating number
There's some confusion here. The Abs Function returns the unsigned magnitude of the argument. eg Abs(-1) = 1, Abs(1) = 1.
You can adjust the number of decimal places displayed via the Format statement eg Debug.Print Format(sngNumber, "0.0000")
-
May 18th, 2008, 06:29 AM
#5
Re: How to get absolute value for floating number
Note also that most floating-point data types (such as Single and Double) do not store data accurately.
It is possible that a number like 2.11324 would actually be stored as just 2.11, and if so there is no way to get the extra precision back.
If you want floating-point numbers with accuracy, try using the Currency data type instead.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|