Forums > MaxMSP

### no decimals – how to …

Jul 05 2010 | 3:24 pm

hi!

When Im for example are using the cv.jit.track object and are opening the helpfile an example comes up. the tracking number is very long and exact. how do I make this number not that exakt, without all the decimals?

for example a number can be very long like:
103.942093 98.861748 1.

what if I want to make this to only display the first two numbers like:
103 98

and skip the last part after the dot .

been searching the forum and in the tutorial but cant find any answer to this

thanks

Perik

Jul 05 2010 | 4:06 pm

Round up to the nearest 1 with the [round ] object, or truncate to an integer using the [i ] object.

Jul 05 2010 | 4:24 pm

thanks!

now I get:
103. 94. 1.

how do I get rid of the last 1.
103.942093 98.861748 [1.]

or after using round
103. 94. [1.]

/ perik

Jul 05 2010 | 6:44 pm

I’m assuming that these values are in a list? If so, just put them through [zl slice 2].

Jul 05 2010 | 11:56 pm

If you want a bit more precision: multiply the long decimal by 100. (WITH the dot so it’s a float calculation), use [round], then multiply by 0.01 to get back to the original range. This way you keep the next two digits, if you care…

Also, any list can be put through a message box which simply says \$1 \$2. this will keep only the first two elements. you have up to \$9 only though, so if you need more, look to the almighty [zl].

Jul 06 2010 | 8:06 am

Isn’t that the same as doing [round 0.01]?

Jul 06 2010 | 1:01 pm

hi!

thanks!

one last question. how do I do if i want to change the span?

If Im by using the round object is getting the result:
103. 94.

the highest result that is possible to get here is:
320 240

so the span is between:
1->320
and
1->240

what if I want to make the span instead between
1->107
and
1->80

simply. How do I change tha span?

I couldnt find this in the tutorials. are there any site you can recommend that is going through these recalculations?

thanks once again?

Jul 06 2010 | 1:19 pm

Try the scale object. It’s all in the tutorials somewhere I think.

Although I recommend doing the scaling in floating point, and then rounding to int after you have the desired output range.

``````-- Pasted Max  Patch, click to expand. --

```
```
Viewing 8 posts - 1 through 8 (of 8 total)

Forums > MaxMSP