COMPGROUPS.NET | Post | Groups | Users | Stream | Browse | About | |

### Largest/smallest Integer

• Email
• Follow

```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
Reply vpsanand (16) 3/28/2006 5:06:57 AM

See related articles to this posting

```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
Reply ellieandrogerxyzzy (4806) 3/28/2006 5:47:14 AM

```Thanks Mate !! You are a legend.

Cheers ! :)

```
 0
Reply 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...
> 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

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

Cheers!
--
Vig

```
 0
Reply 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 ...
added to knowledge !! :)

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
Reply 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:

> In article <1143522417.678415.71590@g10g2000cwb.googlegroups.com>, "VPSA"
> <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
Reply ellieandrogerxyzzy (4806) 3/28/2006 7:38:21 AM
 comp.soft-sys.matlab 203652 articles. 536 followers.

5 Replies
263 Views

Similar Articles

[PageSpeed] 45

• Email
• Follow

Similar Artilces:

find smallest integer such that...
Guys, thanks a lot for all your answers concerning my last question. I am still learning a great deal about Mathematica. Here's a second puzzle. Given an expression e(k,w) 10^i(-k - w) find the smallest w such that the term is smaller than a predescribed bound b. For growing w the term is decreasing and converging towards 0. Your help is very appreciated. Best, Thomas ...

largest and smallest values
helllo, i really need help the question is ; write a program that works out the largest and smallest values from a set of 10 input numbers. A.S.A.P. "Zulhafiz " <zulh90@yahoo.com> wrote in message <greocq\$67f\$1@fred.mathworks.com>... > helllo, > > i really need help > > the question is ; > write a program that works out the largest and smallest values from a set of 10 input numbers. > > A.S.A.P. This is total state of the art. You should use the newly implemented "max" and "min" functions. But it's like total hardcor...

find the smallest integers
the program to find smallest of several integers, then it assume that first value read specific the number of values to input rom the users. If i can get the value specify the input from the reader, then i know i can finish the other let me know. import java.util.Scanner; public class Input { public static void main (String args[]) { Scanner input = new Scanner(System.in); int counter=1; int smallestnumber=0; int values=0; int number=0; { System.out.printf("Indicate how many values you want to input:"); values =input.nextInt(); while ( counter<=values) { Syste...

finding smallest integer
hi any one can help me, i want to write to matlab code to compute the smallest integer L_i , i = 1 : n for the equation (x_i + y_i) * (sum F_i(r_i) , r_i = 0 : L_i) - z_i*lambda_i*F_i(L_i) > = x_i where x_i, y_i, z_i, lambda_i, are given vectors for i = 1 : n and F_i (r_i) is a function of r_i thank you for your help in advance Dear ADEL, What have you done so far? Kind regards, Jan "Jan Simon" wrote in message <j263k9\$ep7\$1@newscl01ah.mathworks.com>... > Dear ADEL, > > What have you done so far? > > Kind regards, Jan Hi Jan % ...

Finding smallest integer division?
In Ruby, what would be the most efficient way to find the smallest number that an array of different numbers can be divided by with integer math? For example: [1,2] would return 2 [1,2,3] would return 6 [1,2,4] would return 4 [1,2,3,4] would return 12 Best regards, Jari Williamsson > what would be the most efficient way to find the smallest > number that an array of different numbers can be divided by with integer > math? Are you looking for the lcm? [1,2,4].inject(1) {|l, n| l.lcm(n)} On Feb 15, 2008, at 1:49 PM, Jari Williamsson wrote: > In Ruby, what would be the mo...

Calculating largest and smallest distances
dears I have a closed polygone with coordinates.Can I calculate the largest length ('' major diameter'') and the shortest distance ('' minor diameter of that polygone'' that passes throuh the centroid. clear all clf axis([0 10 0 10]) set(gca,'TickLength',[0.02 0.025],'Nextplot','add') xy=[ ]; button=1; while button==1 [x,y,button]=ginput(1); plot(x,y,'b.') xy=[xy;x y]; end x=xy(:,1); y=xy(:,2); n=length(x); x2=[x(2:n); x(1)]; y2=[y(2:n);y(1)]; Lmax=max(sqrt((x2-x).*(x2-x)+(y2-y).*(y2-y))); Lmin=min(sqrt((x2-x).*(x2...

displaying the largest and smallest number
I have to write a program that allows the user to enter a series of integers and -99 when they want to exit the loop. How do I display the largest and smallest number the user entered? Keke922 writes: > I have to write a program that allows the user to enter a series of integers > and -99 when they want to exit the loop. How do I display the largest and > smallest number the user entered? Establish two variables, smallest and largest. The first number you read is both the largest *and* smallest. For the rest of the numbers see if that number overrides an earlier decision. keke...

Determine largest integer (ANS)
Is there an ANS word to get the largest integer? I have some code to round up to an even address (for odd length strings). I mean something like: HEX BIGGEST-INT U. FFFFFFFF ok Or something like that... I'm getting around it with the following fragment: : round-up ( len1 -- len2) 1+ [ -1 1- ] LITERAL AND ; Which obviously works, but might lead to raised eyebrows... On 12/11/12 12:04 PM, Mark Wills wrote: > Is there an ANS word to get the largest integer? > I mean something like: > > HEX BIGGEST-INT U. > FFFFFFFF ok S" MAX-U" ENVIRON...

largest value for INTEGER 4
It's larger than 9999. What does the 4 refer to? Thanks. gimme_this_gimme_that@yahoo.com wrote: > It's larger than 9999. What does the 4 refer to? Thanks. I frankly have never seen this syntax for integer with DB2, but presumably it means 4-byte INTEGER (like FLOAT(4) is a 4-byte float) INTGER 2 would be a 2 byte smallint and 8 a big integer (8 bytes). Cheers Serge -- Serge Rielau DB2 Solutions Development IBM Toronto Lab IOD Conference http://www.ibm.com/software/data/ondemandbusiness/conf2006/ Thanks Serge, It must be a AQT (Advanced Query Tool) thing....

Largest possible value of Integer Constants
How can I get the largest possible value of the Integer Constants and use it in the program for these types: 1. int 2. long 3. unsigned short Thanks Nicholas wrote: > How can I get the largest possible value of the Integer Constants and use it > in the program for these types: > 1. int > 2. long > 3. unsigned short #include <limits.h> INT_MAX, LONG_MAX, USHRT_MAX. And many more. See http://www-ccs.ucsd.edu/c/limits.html . -- Tom Zych This email address will expire at some point to thwart spammers. Permanent address: echo 'gbzmlpu@cbobk.pbz' | rot13 Tom Zy...

The smallest and largest values of numeric types
Hi! How can I determine the smallest and largest values of numeric types (for example int) possible in my system? I think there exists a function for this task but I don't know it. In article <QA4Vh.122\$Bz6.77@read3.inet.fi>, tom@finland.com wrote: > Hi! > How can I determine the smallest and largest values of numeric types > (for example int) possible in my system? I think there exists a function > for this task but I don't know it. There is or was a module called "kinds" which was an implementation of PEP 0242. I have it and it gives the values y...

How to find the smallest positive integer n
Hi, please give me a favour to solve the question. Find the smallest positive integer n such that (d/dx)^n(sin(x)^5--sin(x^5))|x=0 is non-zero. Thank you very much. xl31 wrote: > Hi, > please give me a favour to solve the question. > > Find the smallest positive integer n such that > (d/dx)^n(sin(x)^5--sin(x^5))|x=0 is non-zero. > > Thank you very much. > > Looks like a homework exercise to me. I think you should solve it yourself. Tony Tony Roberts wrote: > > xl31 wrote: > > Hi, > > please give me a ...

smallest positive integer that has exactly k divisors
Hello everybody . i have to find the smallest positive integer that has exactly k divisors. for example if k=6 then 12 is the minimum number which have 6 divisors.One brute force approach i came across is find the prime factorization and calculate the factors until factors are equal to the k but this one is taking to much time even for 2000 factors . mukesh tiwari said: > Hello everybody . i have to find the smallest positive integer that > has exactly k divisors. for example if k=6 then 12 is the minimum > number which have 6 divisors.One brute force approach i came across &...

Finding next largest/smallest floating point value
I have a floating point number. I'd like to get the nearest floating point number that is larger or smaller than the given number. I investigated FLT_EPSILON but it only seems to be useful if the given number is 1. Any suggestions? Thanks, -Peter Peter Ammon wrote: > I have a floating point number. I'd like to get the nearest floating > point number that is larger or smaller than the given number. I > investigated FLT_EPSILON but it only seems to be useful if the given > number is 1. Any suggestions? > You have to scale epsilon to find the number that res...

Largest and smallest real numbers Fortran is capable of handling
How do I find the largest and smallest real numbers my Fortran77 compiler (gcc) is capable of handling. For example, in C, I'd check (if I remember correct) REAL_MAX and REAL_MIN in the header file limits.h. How do I do this in Fortran77? eric948470 <eric948470@gmail.com> wrote: > How do I find the largest and smallest real numbers my Fortran77 > compiler (gcc) is capable of handling. For example, in C, I'd check > (if I remember correct) REAL_MAX and REAL_MIN in the header file > limits.h. How do I do this in Fortran77? You look in the compiler document...

Algorithm to find nth largest or nth smallest in a range
I need to write an algorithm that sheds the outliers in a large data set, for example, I might want to ignore the smallest 2% of values and find the next smallest. Boost has a nth_element algorithm, however, it partially sorts the data. I have a requirement that the data remain in the orginal order. Of course I could make a copy of the vector or array and then apply nth_element, but this would be expensive in memory and would require another pass through the data. Does anyone know of a more efficient algorithm that meets my requirements? TIA Code4u wrote: > I need to write an algorithm th...

maple computing the smallest prime factor of an integer command
Does anyone know how can I can compute the smallest prime factor of an integer such that, for example Command(8637) will output 3 Thanks in advance Mary Castleford schrieb: > Does anyone know how can I can compute the smallest prime factor of an > integer such that, for example Command(8637) will output 3 spf := n -> op(1,op(1,op(1,ifactor(n, easy)))): seq(spf(i),i=8630..8640); 2, 3, 2, 89, 2, 5, 2, 3, 2, 53, 2 "Peter Luschny" <venice@luschny.de> wrote in message news:eocufp\$2go\$1@online.de... > Mary Castleford schrieb: > &g...

Text Size -> Largest, Larger, Medium, Smaller, Smallest
Is there a way to use javascript to increase the overall document text size, just like if you click View->Text Size->Largest, Larger, Medium, Smaller, Smallest? This is on IE browser. dmsy@yahoo.com wrote: > Is there a way to use javascript to increase the overall document text > size, just like if you click View->Text Size->Largest, Larger, Medium, > Smaller, Smallest? This is on IE browser. You could dynamically alter the style.fontSize property of the body element - but why bother? Browsers already come with a way for the user to choose their font size, there's ...

bignums, and the "largest 'sane' integer"
well, I went and implemented bignums. currently, the maximum is 256 bits, but I am left wondering: is this enough?... actually, sanely I could ask myself "why would I need bignums anyways?", but yeah... it is like, one implements 256 bit numbers, and then they no longer seem all that large. yes, I can see that 1<<254 is: 28948022309329048855892746252171976963317496166410141009864396001978282409984 but, then it seems like I need bigger numbers... partly feeling tempted to increase the limit to 1024 bits, but really this seems hard to justify... but do I really need 3...

World's Largest and Smallest Hobby Robots of Record
Tried Guiness Anyone got leads to locating the current largest and smallest hobby robots of record? David "David" <geercon@alltel.net> wrote in message news:d17560d2.0309181057.2c3e2f47@posting.google.com... > Tried Guiness > > Anyone got leads to locating the current largest and smallest hobby > robots of record? > > David Define "hobby". One man's hobby is another man's government project! ;) "Edward Dunaway" <eddiebod@earthlink.net> wrote in message news:<yNoab.40488\$Aq2.2163@newsread1.new...

Selecting k smallest or largest elements from a large list in python; (benchmarking)
Given: a large list (10,000,000) of floating point numbers; Task: fastest python code that finds k (small, e.g. 10) smallest items, preferably with item indexes; Limitations: in python, using only standard libraries (numpy & scipy is Ok); I've tried several methods. With N = 10,000,000, K = 10 The fastest so far (without item indexes) was pure python implementation nsmallest_slott_bisect (using bisect/insert). And with indexes nargsmallest_numpy_argmin (argmin() in the numpy array k times). Anyone up to the challenge beating my code with some clever selection algorithm? ...

Generates integer literal of the largest value a variable can hold. Macro takes only variable-name.
Assume you have a variable called var of unknown type. (Or that the type can be changed). How can one construct a literal, to be the largest value that this variable can hold, without information about the variables type? #include <stdio.h> #define MAX_VALUE_OF_VAR(var) (how should this macro look like, please use helper macros if necessary) int main() { signed char var = 0; // only change this line (to other types) do { ++var; printf("%lld, ", (long long int) var); } while (var != MAX_VALUE_OF_VAR(var)); return 0; } In the above, I currently e...

[News] GNU/Linux "Used in Everything from the Smallest Consumer Electronics to the Largest Super Computers"
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 How the Internet makes us stupid – or not ,----[ Quote ] | But he’s wrong about Linux. When Helsinki- | born Linus Torvalds first posted a fledgling | version of Linux on an obscure software | bulletin board, no one – apart from the most | diehard open source evangelists – would have | predicted that open-source software would be | much more than a short-lived hackers’ | experiment. And yet, within a few short | years Linux became the largest software | engineering project on the planet and | spawned a multibillion-dollar ecosystem that...

What's the smallest/fastest CLB/Slice/Lut based unsigned integer 64 bit by 64 bit multiplier/squarer design?
I've been looking at the various core/macro generators and they all seem horribly large and slow, almost like student designs. Has anyone seriously taken a good look at hand fitting multipliers and squarers into Altera/Xilinx FPGA's? In article <1180769858.872726.132740@i13g2000prf.googlegroups.com>, Totally_Lost <air_bits@yahoo.com> wrote: >I've been looking at the various core/macro generators and they all >seem horribly large and slow, almost like student designs. Has anyone >seriously taken a good look at hand fitting multipliers and squarers >into Al...