Properties
Similar Topics
Statistics
Comments
6
Participants
3
Subscribers
0
Votes
1
Views
1489
Share
Answered
Hi,
With Java-Script problems
Where the mistake?
Roman Chijner
- a1=ggbApplet.getValue('a1');
a2=ggbApplet.getValue('a2');
a3=ggbApplet.getValue('a3');
ggbApplet.evalCommand('M1='+a1+'' );
ggbApplet.evalCommand('M2='+a2+'' );
ggbApplet.evalCommand('M3='+a3+'' );
Files:
Unbenannt.PNG
- GeoGebra
- Help
- Partners
-
Contact us
- Feedback & Questions
- This email address is being protected from spambots. You need JavaScript enabled to view it.
- +43 677 6137 2693
© 2022 International GeoGebra Institute
Hi, the problem is that a2 yelds : 5e-7 (try alert(a2+'');) and if you write M2=5e-7 then you have what is displayed : 5 exp(1)-7
A workaround for the moment : use .substring(4) that delete the 4 first characters : <a><2><space><=> from a2 = 0.0000005
a1=ggbApplet.getValueString('a1').substring(4);
a2=ggbApplet.getValueString('a2').substring(4);
a3=ggbApplet.getValueString('a3').substring(4);
ggbApplet.evalCommand('M1='+a1);
ggbApplet.evalCommand('M2='+a2 );
ggbApplet.evalCommand('M3='+a3 );
Cheers. Michel
@ Michel
Thank you for your prompt reply .Now I understand the origin of the numbers.
In the representation of numbers,
Can you, please, explain the meaning of the substring(4) (e g why not substring(5) ? or 6 ...) (a2=15*10^(-12 ))
...that delete the 4 first characters : from this number? or from name: <a> <2> <space> =
If the number (e.g. a=12* 10-7) is calculated in the Jscript -how it can be displayed? (With alert(...+'') is OK!)
Thanks for your help. Roman Chijner
var a="01234567"
a.substring(4) yelds : "4567" ,
this command let us keep the part of the string from the index 4 to the end (knowing that the first index is 0).
Hi,
@ Michel thanks again
I have a little the same problem
Let in the j-script (as a result of the calculations) is the number abs(r2)<10^(-6).
How can it be added to a GGB file?
Roman Chijner
r1=1.000000001234567812345
r2=0.000000001234567812345
alert('r1=1.000000001234567812345→'+r1+'\n'+'r2=0.000000001234567812345→'+r2)
ggbApplet.evalCommand('r1='+r1);
ggbApplet.evalCommand('r2='+r2);
This should be more robust:
as 5E-7 is correct in GeoGebra, JavaScript gives 5e-7 (by default, but understands 5E-7 too)
@Michael Borcherds
Thank you very much. Works !!!
Pity that “e“ and „E“ are not synchronized
I think it will be convenient to use the function
function noo(a) {
return (a+'').replace('e','E');
}
r1=1.000000001234567812345
r2=0.000000001234567812345
ggbApplet.evalCommand('r1='+noo(r1));
ggbApplet.evalCommand('r2='+noo(r2));
Comments have been locked on this page!