Announcement

Collapse
No announcement yet.

240 / 10 = 23,9999

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Awesome! Thanks to all of you!

    1. Got a better undestanding of how this all works
    2. I updated my BP, using Delta Seconds.
    3. Use the "To Text (Float)" function in my "Timer Board" BP.


    Works like a charm!

    Leave a comment:


  • replied
    You probably don't need to worry about floats for now. However do keep in mind that you need to learn it in the future.
    If the counter is going to run for about 100 hours you will have some problems

    For user interface output this may be of interest:
    https://docs.unrealengine.com/latest...at_/index.html
    You can set up the number of digits after the comma etc. and the nodes takes care of rounding for you.

    Leave a comment:


  • replied
    Nowadays its normal to use the delta secs, because of the amount of seconds your pc needs between to ticks depends on its hardware.

    E.g.

    A fast pc can process 200 ticks in 1 second.

    A slower one can process only 30 per second.
    Last edited by SchnitzelDude; 02-17-2015, 11:11 AM.

    Leave a comment:


  • replied
    The use of Delta Seconds sounds reasonable.
    I will give this a try!

    Thanks!

    Leave a comment:


  • replied
    If you want to build a timer, I wouldn't do it like this.

    I would use the delta seconds from event tick and just count them -> time += deltaSeconds;

    Quote from User Guide

    [ATTACH=CONFIG]25898[/ATTACH]
    Attached Files
    Last edited by SchnitzelDude; 02-17-2015, 10:53 AM.

    Leave a comment:


  • replied
    Hi,

    full seconds aren't exact enough, I need 1/10 seconds.
    So I thought "take a float, since Int is a round number".
    Float = something around 24.567 (what ever) * 10 = 245 /10 : = 24.5(float) // Print this and I'm done.


    If I understand you all correct, I will make an int, (logically defined as 1/10 of a second) and add 1 every 0.1 seconds.
    A value of 245 represents 24.5 seconds

    Then I need to update my "Display Time" BPs, to format it as xx.x.

    This way I don't have to handle with floats and it will work fine (as far as I think ).

    Thank you all for your patience!
    Alex
    Last edited by nn23; 02-17-2015, 10:53 AM.

    Leave a comment:


  • replied
    You could use floor.

    Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	86.3 KB
ID:	1066609

    Just curious, why are you counting at 0.1 and then times by 10?

    Narg
    Last edited by Narghile; 02-17-2015, 10:31 AM.

    Leave a comment:


  • replied
    You round it to int but after that you cast it to float. But you have to keep the int and do a int-division:

    currently:

    float(int) / float = float

    you want:

    int / int = int

    Link to docs

    Leave a comment:


  • replied
    just divide 2 integers instead of float and the result should also be an integer.

    In your case:


    when your "Round (or Cast to Int)" to int. Do a int / int division instead of float / float
    Last edited by Wallhalla; 02-17-2015, 10:22 AM.

    Leave a comment:


  • replied
    to put it simple: your computer is just not able to represent decimal values in an accurate way.
    And he is doing mistakes the whole time you run your computer, the reason why you dont see any mistakes usually is that f.e. your operating system can handle all occuring errors that happen.

    So for the future every time you are working with floats,doubles or whatever... just never try to check if two decimal variables are "==". And if you divide some decimal values never expect them to have the value you would have when you solve it on a piece of paper

    Leave a comment:


  • replied
    Sorry to bother you.

    What do you mean with "Cast to int"?

    Before making the division I convert the float to an Int with the value 240 (for example). Then I divide it by ten and get the result 23.99999

    Here's the Char BP:

    Click image for larger version

Name:	Time.png
Views:	1
Size:	174.4 KB
ID:	1066606

    Leave a comment:


  • replied
    Oh - you are right. That should work in this case.
    Last edited by SchnitzelDude; 02-17-2015, 08:52 AM.

    Leave a comment:


  • replied
    You just need to cast your float to integer and then do the operations.

    Leave a comment:


  • replied
    Another simple example is: 3 * (1/3) = 1;

    You can easily say that the result is 1, but in your code (1/3) represents sth like 0.3333 and 0.3333 * 3 equals 0.9999.

    If you want to have 2 decimal places, a simple workaround would be to do it like this:

    Round(F * 100) / 100

    That should work, currently I can't test it.

    Leave a comment:


  • replied
    Thank you for the Link!
    I get an idea of the "problem". But to really understand I need to read this a few times.
    Is there a simple way around? I just need a simple lap timer.

    P.S. @SchnitzelDude
    Bist du am 21. in Köln dabei?

    Leave a comment:

Working...
X