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
EOS question
- boundupone
- Explorer At Heart

- Posts: 614
- Joined: Sat Jun 01, 2013 8:01 pm
- Gender: Male
- Sexual Orientation: Straight
- I am a: Switch
EOS question
Try anything once!
-
undeniable_denial
- Explorer At Heart

- Posts: 109
- Joined: Sat Aug 24, 2019 11:42 am
- Gender: Male
- Location: Germany
Re: EOS question
Code: Select all
volume.toFixed(1)-
kerkersklave
- 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
The reason for that is that Javascript uses binary floating point numbers to represent numbers.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%
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.
- boundupone
- 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
Thanks, where do i input this code in EOS?undeniable_denial wrote: Wed Feb 12, 2020 9:56 pmRounds it to 1 decimal place even if it's zero (and also converts it to a string, e.g. "40.0")Code: Select all
volume.toFixed(1)
Try anything once!
- boundupone
- 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
Thanks, that does work, so is a fairly easy workaroundkerkersklave wrote: Thu Feb 13, 2020 12:47 amThe reason for that is that Javascript uses binary floating point numbers to represent numbers.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%
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.
Try anything once!
-
undeniable_denial
- Explorer At Heart

- Posts: 109
- Joined: Sat Aug 24, 2019 11:42 am
- Gender: Male
- Location: Germany
Re: EOS question
In the Say-action. It doesn't modify the volume variable. It's just formatting.boundupone wrote: Sat Feb 15, 2020 9:17 pmThanks, where do i input this code in EOS?undeniable_denial wrote: Wed Feb 12, 2020 9:56 pmRounds it to 1 decimal place even if it's zero (and also converts it to a string, e.g. "40.0")Code: Select all
volume.toFixed(1)
