Handling Currency Values

Is there some way to handle currency? I’d like to input currency values like £56,000 and be able to display values in the same format. (I’m new to CL, so apologies if this is well known, but a ‘currency’ search offered nothing).

There’s no formatting. There’s basically text or math. I’m not sure your purpose. In a table? Input? There’s a round() function in a graph (accessible in CL), or integer in CL, if you’re only aim is to have a certain number of decimal places. You can’t limit student input to a certain format, but you could have warning messages based on criteria.

Many thanks for the clarification. I experimented before posting and found that for input, typing “$56,000” gives me the number “56000” but entering “£56,000” fails. “56,000” always works, so is there a way to take in “£56,000” as text, strip out the “£”, and then convert to a number?

Failing that I’d like to give students a helpful error message when “£56,000” is entered. Is that what you meant by “warning messages based on criteria”?

On output, it would be nice to have commas added, but I guess “£56000” is okay.

This is supporting a simple exercise in deducting tax from a salary.


You might be able to take “£56,000” and make a simpleFunction with £ as a variable, and evaluateAt(1). Something like this will give the 56000 I think (if Desmos accepts “£” as a variable):

output= simpleFunction(inputName.latex,"£").evaluateAt(1)


errorMessage: when isUndefined(this.numericValue) "Try without £"
otherwise "" 

If it’s a table cellErrorMessage(row,column)

Sorry Daniel, that produces the dreaded NaN! It does feel as if there should be some straightforward way to strip the first character off an input string…or at least check if a character/substring is part of the string. I’ll keep experimenting.


1 Like

I realise I’m coming in late on this thread but the best solution I know of, at the moment, is to use the suffix sink. It would be cool if there were a prefix sink so you could match the conventions of writing money.

suffix: "pounds"
suffix: "dollars"

1 Like

I agree about there being some sort of prefix option or a way to have the compiler ignore a short bit of latex. I am trying to figure out how to get a math input to self-check when students enter a recursive equation like: f(x)=f(x-1)+2x-3. The simpleFunction feature is able to ignore the “y=” or the “f(x)=” but … “f(x)=f(x-1)+” is too much. I would love to have the students enter the entire function but I am gonna have play around to make it work some how!

For things like this you can treat f as a variable, and use parseEquation to check the right-hand side.

myFunc= simpleFunction(parseEquation(input.latex).rhs),"x","f")

OMG … That is flipping genius! You are the best … Thank you!