## no decimals – how to …

Jul 5, 2010 at 3:24pm

# no decimals – how to …

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

#51227
Jul 5, 2010 at 4:06pm

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

#183731
Jul 5, 2010 at 4:24pm

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

#183732
Jul 5, 2010 at 6:44pm

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

#183733
Jul 5, 2010 at 11:56pm

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].

#183734
Jul 6, 2010 at 8:06am

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

#183735
Jul 6, 2010 at 1:01pm

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?

#183736
Jul 6, 2010 at 1:19pm

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. –
#183737

You must be logged in to reply to this topic.