If you have a problem or need to report a bug please email : support@dsprobotics.com
There are 3 sections to this support area:
DOWNLOADS: access to product manuals, support files and drivers
HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects
USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here
NEW REGISTRATIONS - please contact us if you wish to register on the forum
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
how to get a fraction in blue
20 posts
• Page 1 of 2 • 1, 2
how to get a fraction in blue
How to get (simplest way) a factional part in blue?
Like 4.543 -> 0.543
rndint(x) works differently than green int philosophy.
Like 4.543 -> 0.543
rndint(x) works differently than green int philosophy.
- Attachments
-
- splitter.fsm
- (1.39 KiB) Downloaded 863 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: how to get a fraction in blue
- Code: Select all
out = in-rndint(in);
- strangeChild
- Posts: 47
- Joined: Sat Apr 27, 2013 8:04 pm
Re: how to get a fraction in blue
Nope. Check the numbers with fraction above #.5, like 3.8
Code int rounds up or down. Green integer splits the integer and fractional part.
Code int rounds up or down. Green integer splits the integer and fractional part.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: how to get a fraction in blue
Yeah... posted without checking (or thinking!)... Sorry.
- strangeChild
- Posts: 47
- Joined: Sat Apr 27, 2013 8:04 pm
Re: how to get a fraction in blue
out = in - rndint(in-0.5);
But only with positive values
For negative and positive values this looks like it works:
(the assembly people can give you a proper solution)
EDIT - final - DOESN'T WORK WITH FLOATS THAT ARE ALREADY INTEGERS... I'll shut up now.
But only with positive values
For negative and positive values this looks like it works:
- Code: Select all
streamin in;
streamout out;
float adj;
adj = 0.5 - (1 & (in<0));
out = in - rndint(in-adj);
(the assembly people can give you a proper solution)
EDIT - final - DOESN'T WORK WITH FLOATS THAT ARE ALREADY INTEGERS... I'll shut up now.
Last edited by strangeChild on Sun Sep 15, 2013 6:00 pm, edited 3 times in total.
- strangeChild
- Posts: 47
- Joined: Sat Apr 27, 2013 8:04 pm
Re: how to get a fraction in blue
Need for both - positive and negative values.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: how to get a fraction in blue
Was editing last post when you replied... but as I said the assembly guys will give you something much better but this does seem to work.
- strangeChild
- Posts: 47
- Joined: Sat Apr 27, 2013 8:04 pm
Re: how to get a fraction in blue
Yeah, just came to similar thing, but I was wondering - if there is a simpler, "one operation" way.
- Attachments
-
- splitter1.fsm
- (1.85 KiB) Downloaded 827 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Feel free to donate. Thank you for your contribution.
- tester
- Posts: 1786
- Joined: Wed Jan 18, 2012 10:52 pm
- Location: Poland, internet
Re: how to get a fraction in blue
This doesn't look simpler, but actually it's a lot faster.
- Attachments
-
- Stream fraction (MyCo).fsm
- (1.85 KiB) Downloaded 878 times
-
MyCo - Posts: 718
- Joined: Tue Jul 13, 2010 12:33 pm
- Location: Germany
Re: how to get a fraction in blue
for something that looks simple...
I missed that there's a modulus divide.
- Code: Select all
out = in%1;
I missed that there's a modulus divide.
- strangeChild
- Posts: 47
- Joined: Sat Apr 27, 2013 8:04 pm
20 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 54 guests