EOS question

All about the past, current and future webteases and the art of webteasing in general.
---
Post Reply
User avatar
boundupone
Explorer At Heart
Explorer At Heart
Posts: 614
Joined: Sat Jun 01, 2013 8:01 pm
Gender: Male
Sexual Orientation: Straight
I am a: Switch

EOS question

Post by boundupone »

Hi guys,

I have started working on Estim Experiment day 2

I have a small issue. I am using Lolol's method of controlling volume, but I am finding when I use var

volume = volume + 0.1

And use say <volume>

The numbers go strange.

For example I start at 40%, but quickly it has gone to something like 40.800000000002%

Can anyone tell me a way to solve this. I don't mind the actual vol being a random long number, but when the mistress is telling you the volume it should be a nice 40.80% for example

Cheers
Try anything once!
undeniable_denial
Explorer At Heart
Explorer At Heart
Posts: 109
Joined: Sat Aug 24, 2019 11:42 am
Gender: Male
Location: Germany

Re: EOS question

Post by undeniable_denial »

Code: Select all

volume.toFixed(1)
Rounds it to 1 decimal place even if it's zero (and also converts it to a string, e.g. "40.0")
kerkersklave
Explorer At Heart
Explorer At Heart
Posts: 709
Joined: Sun Jul 06, 2014 2:11 pm
Gender: Male
Sexual Orientation: Open to new ideas!
I am a: Slave

Re: EOS question

Post by kerkersklave »

boundupone wrote: Wed Feb 12, 2020 9:42 pm For example I start at 40%, but quickly it has gone to something like 40.800000000002%
The reason for that is that Javascript uses binary floating point numbers to represent numbers.
You are using decimal floating point numbers.
A number like 0.1 to basis 10 cannot be represented in basis 2 with a finite number of digits.

If you use powers of 1/2 like 0.5, 0.25, 0.125, 0.0625 and sums of them, you will not have that problem.
(At least as long as the fractions will not get too small, but you will not need fractions that small).

If you do not want to limit yourself to such numbers, an other way is to use fractions to a denominator, e.g. x/1000.
Then you keep the numerator x as a variable and only compute the fraction whenever you need it.

Increasing and decreasing a floating point number over time with arbitrary fractions will always result in impressions accumulating. It is one of those things you should always avoid in programs.
User avatar
boundupone
Explorer At Heart
Explorer At Heart
Posts: 614
Joined: Sat Jun 01, 2013 8:01 pm
Gender: Male
Sexual Orientation: Straight
I am a: Switch

Re: EOS question

Post by boundupone »

undeniable_denial wrote: Wed Feb 12, 2020 9:56 pm

Code: Select all

volume.toFixed(1)
Rounds it to 1 decimal place even if it's zero (and also converts it to a string, e.g. "40.0")
Thanks, where do i input this code in EOS?
Try anything once!
User avatar
boundupone
Explorer At Heart
Explorer At Heart
Posts: 614
Joined: Sat Jun 01, 2013 8:01 pm
Gender: Male
Sexual Orientation: Straight
I am a: Switch

Re: EOS question

Post by boundupone »

kerkersklave wrote: Thu Feb 13, 2020 12:47 am
boundupone wrote: Wed Feb 12, 2020 9:42 pm For example I start at 40%, but quickly it has gone to something like 40.800000000002%
The reason for that is that Javascript uses binary floating point numbers to represent numbers.
You are using decimal floating point numbers.
A number like 0.1 to basis 10 cannot be represented in basis 2 with a finite number of digits.

If you use powers of 1/2 like 0.5, 0.25, 0.125, 0.0625 and sums of them, you will not have that problem.
(At least as long as the fractions will not get too small, but you will not need fractions that small).


If you do not want to limit yourself to such numbers, an other way is to use fractions to a denominator, e.g. x/1000.
Then you keep the numerator x as a variable and only compute the fraction whenever you need it.

Increasing and decreasing a floating point number over time with arbitrary fractions will always result in impressions accumulating. It is one of those things you should always avoid in programs.
Thanks, that does work, so is a fairly easy workaround
Try anything once!
undeniable_denial
Explorer At Heart
Explorer At Heart
Posts: 109
Joined: Sat Aug 24, 2019 11:42 am
Gender: Male
Location: Germany

Re: EOS question

Post by undeniable_denial »

boundupone wrote: Sat Feb 15, 2020 9:17 pm
undeniable_denial wrote: Wed Feb 12, 2020 9:56 pm

Code: Select all

volume.toFixed(1)
Rounds it to 1 decimal place even if it's zero (and also converts it to a string, e.g. "40.0")
Thanks, where do i input this code in EOS?
In the Say-action. It doesn't modify the volume variable. It's just formatting.
Post Reply