extract fraction values from decimal

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sony.m.2007@googlemail.com

    #1

    extract fraction values from decimal

    Hi,
    I have a decimal value and i need to take the digits after decimal
    places(fraction part only).
    Is there any simple functions available other than using string
    functions(searc hing for '.' and take the string after that)
    decimal decimalValue=12 .745
    I need to take .745 as another decimal value only from the
    decimalValue

    Thanks,
    Sony
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: extract fraction values from decimal

    Sony,

    You can always call the Truncate method to get the integral part of the
    decimal, and subtract it from the original:

    decimal decimalValue = 12.745;
    decimal fractionalValue = decimalValue - Decimal.Truncat e(decimalValue) ;

    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    <sony.m.2007@go oglemail.comwro te in message
    news:53a62033-988f-4c02-a49e-4b895c6959e7@l1 6g2000hsh.googl egroups.com...
    Hi,
    I have a decimal value and i need to take the digits after decimal
    places(fraction part only).
    Is there any simple functions available other than using string
    functions(searc hing for '.' and take the string after that)
    decimal decimalValue=12 .745
    I need to take .745 as another decimal value only from the
    decimalValue
    >
    Thanks,
    Sony

    Comment

    Working...