x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Clamp Randomly Slightly Alters Floating-Point Number

Hey Guys,

Found an issue here that took me a little to see exactly what was happening but I wanted to point it out with some screenshots. If you look at the two following images, you will notice that the value falls within the clamps min and max however slightly changes the value and this kind of thing scares me a little in cases where I need the number exactly as I expect it and I've also noticed a problem where values change ever so slightly within the engine and also if lets say I'm entering in 180 degrees into Yaw for a component on a given blueprint, sometimes I get 179.9999999998 and can't get it right on the dot. Someone mentioned this issue before to me and it is slightly annoying so I am assuming the two could be related. I'd really like to see this cleaned up and would be curious what is actually causing it. Another thing that happens is if I am typing 180 for that value or using the slider, it will make it negative sometimes so that's confusing. For the meantime, I just Floor'ed both values and then compared them so that's sufficient for the time being but hope this gets fixed in the near future. Thanks guys and take care.

Here are the screenshots from my Blueprint... alt text alt text

Product Version: Not Selected
Tags:
more ▼

asked Sep 14 '14 at 10:09 PM in Bug Reports

avatar image

MC Stryker
453 22 37 48

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey MC Stryker-

What you are seeing is the approximations that floating point numbers use to represent a finite number. There are some cases where floating point numbers are unable to represent specific values (such as .1 or .01). When working with floating point numbers it is usually best to use either 'greater than' or 'less than' rather than attempting to use 'equal to'. If you do need to compare to an exact number you may want to include a floor node (which will truncate the value) and then use an int instead of float.

Cheers

Doug Wilson

more ▼

answered Sep 18 '14 at 03:30 PM

avatar image MC Stryker Sep 18 '14 at 10:13 PM

Ahhhh, I see. If I do need to see if the value comes out different, would you suggest creating a variable that acts as a threshold with a given range and then going ahead and doing a less than y but greater than x if I need to compare a float for a specific value?

EDIT: To be more specific, let's say I need to check if Z = 1.001 which is what 'Value' is set to. If I create the Variable 'Threshold' and make it equal to 0.01, I would do the above like so...

If (Value >= Z - Threshold && Value

For the time being, I already did the Floor that day and in this case, it works great for that specific area of the Blueprint.

Thanks Doug!

avatar image Doug E ♦♦ STAFF Sep 19 '14 at 02:42 PM

The idea of creating a "buffer" variable is actually not a bad idea. That would give you a bit of a safe zone to catch any kind of minor variation in the float value.

avatar image MC Stryker Sep 19 '14 at 11:38 PM

Awesome, glad to hear you think so Doug! I figured if I needed to address the float, then that would be a good method. Anytime in the past that I have encountered issues where I needed to check the floating-point fraction of a value and maybe the precession isn't reliable or maybe I need some room for error, creating a range and doing the above usually helps in keeping the consistency with a minor loss in precession. Thanks again for your insight on this matter Doug and take care.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question