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

Weird float problem

For general discussion related FlowStone

Weird float problem

Postby User » Sun Aug 08, 2021 3:14 pm

I'm trying to reduce input noise by using an inverted signal with a value of 0.99999994. Problem is that the float primitive is rounding it to 1. Any ideas how to solve it ? Or why is it doing that rounding ?
User
 
Posts: 14
Joined: Wed Jun 30, 2021 6:25 am

Re: Weird float problem

Postby juha_tp » Sun Aug 08, 2021 4:34 pm

User wrote:I'm trying to reduce input noise by using an inverted signal with a value of 0.99999994. Problem is that the float primitive is rounding it to 1. Any ideas how to solve it ? Or why is it doing that rounding ?



Hmm... where do you put that value and where do you see it rounded?
juha_tp
 
Posts: 60
Joined: Fri Nov 09, 2018 10:37 pm

Re: Weird float problem

Postby HughBanton » Sun Aug 08, 2021 8:33 pm

In Options/Advanced there's a tick-box - 'Display floats as 32-bit binary representations'.

If ticked you should see 0.9999994 in a float box; unticked it shows 1. Could this be your issue?

H
User avatar
HughBanton
 
Posts: 265
Joined: Sat Apr 12, 2008 3:10 pm
Location: Evesham, Worcestershire

Re: Weird float problem

Postby User » Mon Aug 09, 2021 12:26 am

Probably that's the issue. I will have to try that. It looks like on a knob it works but it's hard to control it if you want to increase/decrease the value by one unit. I tried to increase the SHIFT precision but it still jumps by 6 units instead of 1. After scrolling for miles. How do you make the knob work in 0.00000001 increments ? There must be some trick. Maybe using one knob for making big adjustments and another one for fine adjustments ?
Last edited by User on Mon Aug 09, 2021 12:41 am, edited 2 times in total.
User
 
Posts: 14
Joined: Wed Jun 30, 2021 6:25 am

Re: Weird float problem

Postby User » Mon Aug 09, 2021 12:37 am

It was doing that in the Float component. It's not doing the rounding anymore after checking that box in the Options/Advanced. Thank you for your help.
User
 
Posts: 14
Joined: Wed Jun 30, 2021 6:25 am

Re: Weird float problem

Postby User » Mon Aug 09, 2021 1:01 am

It looks like it's not allowing anything higher than 0.99999994. It gets rounded either to 1 or back down to 0.99999994. Even after checking the "Display floats as 32bit" box in the Options/Advanced. I guess the problem is still there.
User
 
Posts: 14
Joined: Wed Jun 30, 2021 6:25 am

Re: Weird float problem

Postby User » Mon Aug 09, 2021 2:40 am

Either my Windows 10 is screwy or maybe it has some bugs. I don't know. Just take a float component from the toolbox and type in 0.99999994. Then try to change it into 0.99999996 or 0.99999998. Mine jumps back to 0.99999994 or it gets rounded to 1.
User
 
Posts: 14
Joined: Wed Jun 30, 2021 6:25 am

Re: Weird float problem

Postby HughBanton » Mon Aug 09, 2021 9:51 am

Afaik this is just a display thing, and internally Flowstone calculates the same either way.

Here's what happens when you pass floats through Ruby; the 'Watch' doesn't change whether the 32-bit box is ticked or not. Try ticking & un-ticking.
float_test.fsm
(315 Bytes) Downloaded 756 times

H
User avatar
HughBanton
 
Posts: 265
Joined: Sat Apr 12, 2008 3:10 pm
Location: Evesham, Worcestershire

Re: Weird float problem

Postby User » Mon Aug 09, 2021 8:42 pm

That's interesting but it's still not able to increment that number by 0.00000001. It still jumps in increments of 0.00000006. And if you change 0.99999994 into something like 0.99999990 it gets rounded to 1. The problem is still there even if the 32bit float view is checked.
User
 
Posts: 14
Joined: Wed Jun 30, 2021 6:25 am

Re: Weird float problem

Postby deraudrl » Mon Aug 09, 2021 10:58 pm

User wrote:That's interesting but it's still not able to increment that number by 0.00000001. It still jumps in increments of 0.00000006. And if you change 0.99999994 into something like 0.99999990 it gets rounded to 1. The problem is still there even if the 32bit float view is checked.
Even if display rounding in the text conversion is ignored, the real issue is that the LSB of the mantissa of anything between -0.5 and 0.5 is 2^-24: that's all the resolution you have.

And as it turns out, 2^-24 is roughly 0.00000006. You can represent 0.00000001 very accurately in 32-bit floating point; what you can't do is represent 1.0 minus 0.00000001 accurately: there simply aren't enough bits in the mantissa. This is about the time where Martin or tulamide jumps in to tell me I'm off by a factor of 2 somewhere, but you get my point. The thing is, you can multiply/divide arbitrary FP numbers with great accuracy. Adding them? Not so much, especially when their magnitudes are that far apart.

(I don't recall offhand what FS provides in the way of double-precision primitives...you might give that a shot. But don't be surprised if the displayed values behave oddly if there aren't enough fractional digits displayed.)
I keep a pair of oven mitts next to my computer so I don't get a concussion from slapping my forehead while I'm reading the responses to my questions.
deraudrl
 
Posts: 239
Joined: Thu Nov 28, 2019 9:12 pm
Location: SoCal

Next

Return to General

Who is online

Users browsing this forum: No registered users and 95 guests