how to have 2 or 1 if known 1,2524...

if known 1 number real, how to have number integer minizise that bigger or smaller
EX:
real : 1,421 ->bigger is 2 and smaller is 1
real : 2,6343 ->bigger is 3 and smaller is 2
real : 8,342 ->bigger is 9 and smaller is 8

I'm working on matlab
Last edited on
closed account (28poGNh0)
with a simple bluf I think

1
2
3
4
5
6
7
8
9
10
11
12
13
# include <iostream>
using namespace std;

int main()
{
    float nbr=0;
    cout << "Enter your number -> ";cin >> nbr;

    int nbr2 = (int)nbr;
    cout << nbr << " ->bigger is " << nbr2+1 << " and smaller is " << nbr2 << endl;

    return 0;
}


hope it helps
I'm working on matlab. help
did you know this is not matlab forum? :D
Topic archived. No new replies allowed.