# Weird bug with slider and math

**URL:** <https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [December 1, 2014, 6:25pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275 "2014-12-01T18:25:55Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 1, 2014, 6:25pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/1 "2014-12-01T18:25:55Z")

</div>

what is happening is when i have a slider value for 1 through 100 i take the value floor it to get rid of the decimal point the i have an append where it has 0. then the value then multiplying 1920 and 1080 separately and getting weird values and if anybody can help me figure out how to take blueprint screenshots i can show it

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [December 1, 2014, 6:55pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/2 "2014-12-01T18:55:36Z")

</div>

Hey connormurry-

I’m investigating your issue and want to make sure I understand correctly. You have a slider value (lets say 89.7453) and take the floor (89). Then that gets multiplied by 1920 and 1080 but the results are inaccurate? Please let me know if my understanding of the problem is wrong.

For taking a screenshot, if you hold Alt and press the Print Screen button on your keyboard it will take a picture of just the window that currently has focus. You can then open a program like MS Paint or Photoshop to past the image and save.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 2, 2014, 2:07am UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/3 "2014-12-02T02:07:02Z")

</div>

well its like what i have here

 ![22685-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/6/2/b62626aea17edb6287c234260b01c919c4aa7540.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 2, 2014, 2:07am UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/4 "2014-12-02T02:07:33Z")

</div>

![22686-capture1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/4/a/f4aa685f580deb599ffbd8c26da93a2622cd5930.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 2, 2014, 2:07am UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/5 "2014-12-02T02:07:46Z")

</div>

![22687-capture2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/b/d/3bd03821372e030978bbbb11240d716204da1e95.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 2, 2014, 2:09am UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/6 "2014-12-02T02:09:02Z")

</div>

![22688-capture3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/2/a/e2afddc8dbf1756c93b4ce7758fa25aa5d4209d9.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 2, 2014, 2:09am UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/7 "2014-12-02T02:09:34Z")

</div>

so as you can see its nothing wrong with the blueprint but im pretty confident in my visual scripting abilities

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 2, 2014, 2:24am UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/8 "2014-12-02T02:24:09Z")

</div>

just fyi this was in the editor

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 2, 2014, 2:24am UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/9 "2014-12-02T02:24:26Z")

</div>

this was when the game was full screened

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [December 2, 2014, 2:58pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/10 "2014-12-02T14:58:08Z")

</div>

Hey connormurry-

Rather than multiplying by a static number (such as 1920 or 1080) you are multiplying by the actual viewport size. If the size of the viewport changes it would also change these numbers. So the difference between fullscreen and in editor would be expected. If you change the size of your editor viewport and ran it you would again see different numbers. Connecting a print node after the BreakVector2D will let you see what the resolution of the current viewport is.

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 2, 2014, 6:29pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/11 "2014-12-02T18:29:12Z")

</div>

uh this is not helping me at all i dont want to print out the actual viewport or resolution of the monitor im trying to print out the resolution of the screen divided by the resolution scale to get for say if it was at 50% of 1080p it would be 960 \* 540

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 2, 2014, 6:35pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/12 "2014-12-02T18:35:12Z")

</div>

and i also dont think you get it when the slider is at 100% the resolution output is missing the last number such as instead of showing 1920 \* 1080 it does this 192 \* 108

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [December 2, 2014, 8:06pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/13 "2014-12-02T20:06:50Z")

</div>

How is value being into the event to begin? If it is being stored as an integer you should be able to take the Value/100 to get a decimal form of the value (50% = .5). Then multiply that by the X and Y of your GetViewportSize node. With that you should get the correct ratio without needing the floor or Append nodes.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 3, 2014, 11:34pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/14 "2014-12-03T23:34:34Z")

</div>

well the thing is i am using a slider which i have to floor to get rid of the decimal point it produces

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [December 4, 2014, 8:48pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/15 "2014-12-04T20:48:21Z")

</div>

To get rid of the decimal from the slider’s percent value you would want to floor it before using it. Doing the floor after your calculations will cause greater rounding error.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_95bf9f7e1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_95bf9f7e1](https://forums.unrealengine.com/u/anonymous_user_95bf9f7e1)\
**Post date:** [December 4, 2014, 10:16pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/16 "2014-12-04T22:16:19Z")

</div>

OH! i see i didnt realize that im implementing it now but i doubt it will fix the original problem

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [December 5, 2014, 2:23pm UTC](https://forums.unrealengine.com/t/weird-bug-with-slider-and-math/300275/17 "2014-12-05T14:23:23Z")

</div>

If Value is being passed in as a number (50% = Value of 50 after the floor) then you only need to divide by 100 to turn that into a decimal and multiply by the viewport size. This result will change based on the size of the viewport being used (fullscreened at 1920x1080 will give a different result than a 1024x768 window).
