Javascript and decimal Jan 03, 2013 By Sebastien Greffet Hello ! I have a problem with my Javascript. I mean : I need to have this : "0.005" but when I try it, I always have only two numbers after the dot. Do you have any idea how to handle it ? I'm really lost ... Thank you ! Sébastien
Johanna Stix over 11 years ago01/03/13 at 8:00 am (UTC) Hi Sébastien, could you please post the javascript code? Johanna
Sebastien Greffet Author over 11 years ago01/03/13 at 8:10 am (UTC) There it is : var nbre1 = Math.random(); var player = GetPlayer(); player.SetVar('nbre1', nbre1); I have created a variable in Storyline named 'nbre1'. When I use this code, instead of giving me something like : 0.2536586, it gives me 0.25. Do you have any idea ? Sébastien
Johanna Stix over 11 years ago01/03/13 at 8:44 am (UTC) hi Sebastien you could assign the value to a "text" variable. It's a workaround, but it works Johanna
Sebastien Greffet Author over 11 years ago01/03/13 at 8:50 am (UTC) I test and it works thank you very much Johanna ! You're a pro! But, does it mean that we can't have a number with more than 2 decimals in storyline?
Johanna Stix over 11 years ago01/04/13 at 2:36 am (UTC) I'm not sure, never tested it before. But it seems, that the number variables are formatted by storyline.
Sebastien Greffet Author over 11 years ago01/04/13 at 2:41 am (UTC) Ok. Thank's a lot for your help ! Sébastien
6 Replies
Hi Sébastien,
could you please post the javascript code?
Johanna
There it is :
var nbre1 = Math.random();
var player = GetPlayer();
player.SetVar('nbre1', nbre1);
I have created a variable in Storyline named 'nbre1'. When I use this code, instead of giving me something like : 0.2536586, it gives me 0.25.
Do you have any idea ?
Sébastien
hi Sebastien
you could assign the value to a "text" variable.
It's a workaround, but it works
Johanna
I test and it works thank you very much Johanna ! You're a pro!
But, does it mean that we can't have a number with more than 2 decimals in storyline?
I'm not sure, never tested it before.
But it seems, that the number variables are formatted by storyline.
Ok.
Thank's a lot for your help !
Sébastien
This discussion is closed. You can start a new discussion or contact Articulate Support.