Reputation: 2329
for(i = 0; i < 181; i++)
{
unsigned int index = rint(i/db);
assert(index >= 0 && index < data.ranges_count);
this->laser_ranges[i*2][0] = data.ranges[index] * 1e3;
}
what is the meaning of rint(i/db)
? I am not sure how rint is used...
Upvotes: 1
Views: 1697
Reputation: 58744
rint
rounds to the nearest integer with some error checking.
What really happens here depends on the type of i
and db
of course.
Upvotes: 0
Reputation: 133082
rint
is a function that rounds a floating point number to an integer. It is a non-standard function. If db
is of an integral type, then i/db
will truncate to an integer and the code will not work as you have expected. Otherwise the rint(i/db)
is i/db
rounded to the nearest integer.
As to why the rounding is needed here(insteas of truncation) depends heavily on the context of your problem which we have absolutely no idea about.
Upvotes: 5
Reputation: 129914
It's a call to function named rint
with a single argument, which in this case is i
divided by db
.
Upvotes: 2