Home All Groups Group Topic Archive Search About

truncating decimal on numbers

Author
8 Nov 2006 7:12 PM
cj
I want 7 * .105263 to result in an int32 value of 0.  and 7 * .189021 to
result in an int32 value of 1.

I don't want to round.  How can I just drop the decimal places?

Author
8 Nov 2006 7:18 PM
cj
never mind--I knew as soon as I asked I'd find the answer.  Sometimes
I'm tempted to ask just because I know I'll find the answer as soon as I
hit send.

Int or Fix is what I wanted.


cj wrote:
Show quoteHide quote
> I want 7 * .105263 to result in an int32 value of 0.  and 7 * .189021 to
> result in an int32 value of 1.
>
> I don't want to round.  How can I just drop the decimal places?
Author
8 Nov 2006 11:18 PM
Herfried K. Wagner [MVP]
"cj" <cj@nospam.nospam> schrieb:
>I want 7 * .105263 to result in an int32 value of 0.  and 7 * .189021 to
> result in an int32 value of 1.
>
> I don't want to round.  How can I just drop the decimal places?

Check out 'Fix', 'Int', and 'Math.Floor' and 'Math.Ceil'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
9 Nov 2006 4:59 AM
Cor Ligthert [MVP]
CJ,

You can always use it as string and than cut the decimals you don't want
using the IProvider from ToSring. Is as well an easy way to round in any way
you want.

CJM

Show quoteHide quote
"cj" <cj@nospam.nospam> schreef in bericht
news:O88JJn2AHHA.3396@TK2MSFTNGP02.phx.gbl...
>I want 7 * .105263 to result in an int32 value of 0.  and 7 * .189021 to
>result in an int32 value of 1.
>
> I don't want to round.  How can I just drop the decimal places?