STACK: integer and float variables in algebraic input

STACK: integer and float variables in algebraic input

by Miro Iliaš -
Number of replies: 1

Hello,

imagine that I have algebraic input in STACK question in the form ta:v/N, where v is variable and N is a number.

When N is integer number, let say 150,  the answer m/150 is accepted. However, when N becomes float number, for example 150.1, the answer m/150.1 is not accepted. The proper answer is  0.00666222518321119253830779480346*m  instead, and student has to calculate (1/150.1)

I would need real (float) numbers appearing in algebraic expressions in chemical calculus applications. Any help for that ?

Average of ratings: -
In reply to Miro Iliaš

Re: STACK: integer and float variables in algebraic input

by Leo Butler -
I think there are likely two issues:

  1. in the input: ans section, you need to set forbid float to no;
  2. you need to set simp:false to preserve the form of your expression with a floating-point denominator.
Your question will look like:

simp:false;
N : 150.1;
ta : v/N;

-----

Another method would be to ask for the numerator and denominator separately. I would likely do that since there are fewer pitfalls.

Leo



Average of ratings: Useful (2)