From: Dolchut on
Hi,
say I have the following three negative numbers:
-151.5
-48.78
-32.23

and I just want to truncate it so that the negative integer part remains (removing the decimal). I do not want to round or floor it. And as the number size varies (151, 48, 32), I cannot use precision either...
the result should look like:
-151
-48
-32
It may sound trivial but could use some hint...

cheers
From: Bruno Luong on
"Dolchut " <kazi.ishtiak(a)gmail.com> wrote in message <i14gnk$r6s$1(a)fred.mathworks.com>...
> Hi,
> say I have the following three negative numbers:
> -151.5
> -48.78
> -32.23
>
> and I just want to truncate it so that the negative integer part remains (removing the decimal). I do not want to round or floor it. And as the number size varies (151, 48, 32), I cannot use precision either...
> the result should look like:
> -151
> -48
> -32
> It may sound trivial but could use some hint...
>
> cheers

help CEIL

Bruno
From: Bruno Luong on
also

help FIX

Bruno
From: John D'Errico on
"Dolchut " <kazi.ishtiak(a)gmail.com> wrote in message <i14gpl$1rj$1(a)fred.mathworks.com>...
> Hi,
> say I have the following three negative numbers:
> -151.5
> -48.78
> -32.23
>
> and I just want to truncate it so that the negative integer part remains (removing the decimal). I do not want to round or floor it. And as the number size varies (151, 48, 32), I cannot use precision either...
> the result should look like:
> -151
> -48
> -32
> It may sound trivial but could use some hint...
>
> cheers

Use the help that comes with matlab.

Had I no idea how to solve your problem, I might read
the help for floor, or round, two functions that are
close to what you want to do.

Upon doing, I would see the reference to other, similar
functions. Ceil, for example, or fix.

I might then look at what those functions do. Since
you have not fully specified your problem, I can't know
which of these functions might help you. For example,
what behavior do you wish to see on positive numbers?

Regardless, use of the help that comes with matlab will
solve your problem.

John
From: Jan Simon on
Dear Dolchut,

> -151.5
> -48.78
> -32.23
> and I just want to truncate it so that the negative integer part remains (removing the decimal). I do not want to round or floor it.

Then you want to CEIL it.

> And as the number size varies (151, 48, 32), I cannot use precision either...

I don't know what "using precision" is.

Good luck, Jan