f

#### Largest/smallest Integer

```Hi There,

A question about MATLAB. Is there any function by which we can find
largest Integer upto a real number. I will better put up with an
example. for example you have a real number 9.867 the larget integer
less than this number is 9. How you get it? similarly smallest integer
greater than this is 10 ! how to get that too? Any MATLAB function for
this?

Your help will be well appreciated. I couldn't figure out how/what to
query dumb computers!! so asking intelligent human beings :)

Cheers !!

VPSA

```
 0
vpsanand (16)
3/28/2006 5:06:57 AM
comp.soft-sys.matlab 211266 articles. 18 followers. lunamoonmoon (258) is leader.

5 Replies
867 Views

Similar Articles

[PageSpeed] 55

```In article <1143522417.678415.71590@g10g2000cwb.googlegroups.com>, "VPSA"
<vpsanand@gmail.com> wrote:

> Hi There,
>
> A question about MATLAB. Is there any function by which we can find
> largest Integer upto a real number. I will better put up with an
> example. for example you have a real number 9.867 the larget integer
> less than this number is 9. How you get it? similarly smallest integer
> greater than this is 10 ! how to get that too? Any MATLAB function for
> this?
>
> Your help will be well appreciated. I couldn't figure out how/what to
> query dumb computers!! so asking intelligent human beings :)
>
>
> Cheers !!
>
> VPSA
---------------------
Yes, they are called 'floor' and 'ceil' respectively:

floor(9.867) = 9
ceil(9.867) = 10

(Remove "xyzzy" and ".invalid" to send me email.)
Roger Stafford
```
 0
3/28/2006 5:47:14 AM
```Thanks Mate !! You are a legend.

Cheers ! :)

```
 0
vpsanand (16)
3/28/2006 6:52:22 AM
```"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in
message
news:ellieandrogerxyzzy-2703062147150001@dialup-4.232.63.199.dial1.losangeles1.level3.net...
> <vpsanand@gmail.com> wrote:
>
>> Hi There,
>>
>> A question about MATLAB. Is there any function by which we can find
>> largest Integer upto a real number. I will better put up with an
>> example. for example you have a real number 9.867 the larget integer
>> less than this number is 9. How you get it? similarly smallest integer
>> greater than this is 10 ! how to get that too? Any MATLAB function for
>> this?
>>
>> Your help will be well appreciated. I couldn't figure out how/what to
>> query dumb computers!! so asking intelligent human beings :)
>>
>>
>> Cheers !!
>>
>> VPSA
> ---------------------
>  Yes, they are called 'floor' and 'ceil' respectively:
>
> floor(9.867) = 9
> ceil(9.867) = 10

I would also look into 'round' and 'fix' by typing in 'help round' and 'help
fix' at the command line...

Cheers!
--
Vig

```
 0
vig (18)
3/28/2006 6:57:46 AM
```Vig,

Thanks. This is another piece of useful information and is definately
gonna help in future. i have done what you said, type help fix ...

as in the case of number say 9.687 round and fix are pretty much the
same as ceil and floor respectively. but what if the number is say,
9.34 !! I think they are useful in some other sense.

```
 0
vpsanand (16)
3/28/2006 7:23:24 AM
```In article
<ellieandrogerxyzzy-2703062147150001@dialup-4.232.63.199.dial1.losangeles1.level3.net>,
ellieandrogerxyzzy@mindspring.com.invalid (Roger Stafford) wrote:

> <vpsanand@gmail.com> wrote:
>
> > A question about MATLAB. Is there any function by which we can find
> > largest Integer upto a real number. I will better put up with an
> > example. for example you have a real number 9.867 the larget integer
> > less than this number is 9. How you get it? similarly smallest integer
> > greater than this is 10 ! how to get that too? Any MATLAB function for
> > this?
> ---------------------
>   Yes, they are called 'floor' and 'ceil' respectively:
>
> floor(9.867) = 9
> ceil(9.867) = 10
--------------------
I just noticed that you said, "largest integer less than" and "smallest
integer greater than".  If you really meant "less than" as opposed to
"less than or equal to", and "greater than" rather than "greater than or
equal to", then you should use the following instead of the 'floor' and
'ceil' functions:

-1-floor(-x)  % <-- is the largest integer less than x
1-ceil(-x)   % <-- is the smallest integer greater than x

Note: Remember that all of these inequalities above are the algebraic
kind of inequalities where, for example, -5 is less than -4.

(Remove "xyzzy" and ".invalid" to send me email.)
Roger Stafford
```
 0
3/28/2006 7:38:21 AM