Displaying and rounding numbers in scientific notation

Displaying and rounding numbers in scientific notation

by Armand Majer -
Number of replies: 1

Hello,

my question is related to displaying a certain number of decimal places and the rounding of that digit itself, and the possibility for the student to enter a number with 3 decimal places (e. g. 1,385E10). I've defined my variables as follows (ta5 is the one to be looked at):

cx: rand_with_step(0.01,0.1,0.005); /* koncentrácia NiCl2, elektrolyt */

cz: 0.02;

emnx: rand_with_step(0.5,0.6055,0.001);

emnz: 0.6053;

fox: 101.325; /* kPa */

pox: 101.325; /* kPa */

zx: 2;

tx: 25;

Tdx: 273.15;

Rx: 8.314;

Fx: 96485;

Td: tx+Tx;

vztah_emn: Ek-Ez; /* výpočet EMN */

vztah_emn2: (Eklad)-(Ezap);

vztah_dG_K: -RT*ln(K); /* výpočet ΔG∘ z K */

vztah_dG_dE: -z*F*dE; /* výpočet ΔG∘ z ΔE∘ */

vztah_K: e^(((z*F)/(R*(t+273.15)))*(EMN+((R*(t+273.15))/(2*F))*ln(4*c^3))); /* výsledný vzťah pre výpočet K a vyčíslenie K */

ta1: vztah_emn;

ta2: vztah_dG_K;

ta3: vztah_dG_dE;

ta4: vztah_K;

ta5: decimalplaces(subst([z=zx,F=Fx,t=tx,EMN=emnx,R=Rx, c=cx],vztah_K),3);

The answer for question n. 5 is a number * 10^x. Input n. 5 is set to numeric type.

So, how come I always get a number with several decimal places instead of the defined 3 in ta5? Thank you. smile

Scientific notation, significant figures, decimal places

Average of ratings: -
In reply to Armand Majer

Re: Displaying and rounding numbers in scientific notation

by Björn Gerß -
Hello Armand,

you are looking for the function significantfigures(x,n) I would guess.

Take a look at her:
http://docs.stack-assessment.org/en/CAS/Numbers/#notes-about-numerical-rounding

From my understanding, 3 decimal places are 3 places behind the dot (but not the one that has been moved by 10^x).

So
decimalplaces(1.5*10^3,3) =decimalplaces(1500,3) = 1500.000

but
significantfigures(1.5456*10^3,3)=1.54*10^3