# Return decimal value (1 Viewer)

#### Nita

##### New member
Hi,

I have a query with a value in currency, I convert it to number.
I can't get only the decimals, can you help me?
I am using Access 2016

#### MajP

##### You've got your good things, and you've got mine.
Not sure I understand the problem. Would the round function work?

#### Nita

##### New member
Hi,
I want the decimals values.
I need both of the values in separated fields.
The value before the "," I know how to get, the value after is the problem.
For example 5,55 I have one field that returns 5 and want another to return 55.
Thank you

x - int(x)

#### Nita

##### New member
Thank you... it work

#### cheekybuddha

##### Registered User.
Crossposted on UA

(Just FYI, and because there is extra solution to handle when x < 0)

d

#### MajP

##### You've got your good things, and you've got mine.
Good lesson in floating point arithmitic and things to consider when doing something like this. May not get what you expect without some extra code.
Code:
``````.

Public Sub Test()
Dim x As Double
x = -123.345
Debug.Print Abs(x) - Int(Abs(x))
End Sub

Public Sub Test2()
Dim x As Double
x = -123.345
Debug.Print CDec(Abs(x)) - CDec(Int(Abs(x)))
End Sub``````
The first returns
0.344999999999999
The second returns
0.345

#### cheekybuddha

##### Registered User.
You will get the same result as Test2() if you substitute CDec() for CCur()

I'd be tempted to just declare x As Currency:
Code:
``````Public Sub Test3()
Dim x As Currency
x = -123.345
Debug.Print Abs(x) - Int(Abs(x))
End Sub``````
In Immediate Window:
Code:
``````Test3
0.345``````

#### Nita

##### New member
Crossposted on UA

(Just FYI, and because there is extra solution to handle when x < 0)

d
It's not working because it is currency, I thought that changing it on the properties sheet to number would work but it doesn't

#### Nita

##### New member
Good lesson in floating point arithmitic and things to consider when doing something like this. May not get what you expect without some extra code.
Code:
``````.

Public Sub Test()
Dim x As Double
x = -123.345
Debug.Print Abs(x) - Int(Abs(x))
End Sub

Public Sub Test2()
Dim x As Double
x = -123.345
Debug.Print CDec(Abs(x)) - CDec(Int(Abs(x)))
End Sub``````
The first returns
0.344999999999999
The second returns
0.345
In that case, what I need is to return 345.

#### ebs17

##### Member
Currency defines a fixed-point number with exactly four decimal places. How many decimal places are then displayed is irrelevant and only a matter of display and interpretation. You can therefore use integer calculations immediately.
Code:
``````?123.345 * 10000 mod 10000
3450``````
3450 / 10000 = 345 / 1000

Eberhard