Support

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

For general discussion related FlowStone

how to get a fraction in blue

Postby tester » Sun Sep 15, 2013 4:43 pm

How to get (simplest way) a factional part in blue?
Like 4.543 -> 0.543
rndint(x) works differently than green int philosophy.
Attachments
splitter.fsm
(1.39 KiB) Downloaded 862 times
Need to take a break? I have something right for you.
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

Postby strangeChild » Sun Sep 15, 2013 4:56 pm

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

Postby tester » Sun Sep 15, 2013 4:58 pm

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.
Need to take a break? I have something right for you.
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

Postby strangeChild » Sun Sep 15, 2013 4:59 pm

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

Postby strangeChild » Sun Sep 15, 2013 5:07 pm

out = in - rndint(in-0.5);

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. :oops:
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

Postby tester » Sun Sep 15, 2013 5:16 pm

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.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: how to get a fraction in blue

Postby strangeChild » Sun Sep 15, 2013 5:20 pm

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

Postby tester » Sun Sep 15, 2013 5:20 pm

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 826 times
Need to take a break? I have something right for you.
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

Postby MyCo » Sun Sep 15, 2013 7:59 pm

This doesn't look simpler, but actually it's a lot faster.
Attachments
Stream fraction (MyCo).fsm
(1.85 KiB) Downloaded 877 times
User avatar
MyCo
 
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany

Re: how to get a fraction in blue

Postby strangeChild » Sun Sep 15, 2013 9:02 pm

for something that looks simple...

Code: Select all
out = in%1;

I missed that there's a modulus divide. :lol:
strangeChild
 
Posts: 47
Joined: Sat Apr 27, 2013 8:04 pm

Next

Return to General

Who is online

Users browsing this forum: No registered users and 62 guests