Unpredictable conversion to scientific form

7 views
Skip to first unread message

Martin Jones

unread,
Mar 30, 2022, 8:22:44 AM3/30/22
to Numbas Users
I am using a variable with a value of something like 0.0042.

90% of the time it is displayed as 0.0042 (which is how I prefer). Occasionally it gets converted to standard/scientific form, i.e. 4.2\times10^{-3}. See images below.

I have not been able to find out any pattern about why it does this. It has also mixed these styles in the same question which is not great.

Would it be possible to have an option (perhaps a simplification rule) for converting to scientific form or not?

Regards,
Martin

p2.png

p1.png

Ben Brawn

unread,
Apr 25, 2022, 5:16:05 AM4/25/22
to Numbas Users
I feel like something changed when the decimal data type was added, or maybe it was always that way?

But try the following, look at how your decimal is created and instead of doing say random(0..1#0.0001), try doing something like random(1..100)/10000 or decimal(random(1..100)/10000), and then the final suggestion would be to avoid using simplify unless it has a purpose.

From what I can see 
$\frac{1}{\var{a}}$ where a  is defined as random(1..100)/1000) is never displayed as scientific notation, the same can be said about 
$\simplify{1/{b}}$ where b is defined as decimal(random(1..100)/1000))

However when a variable c is defined as random(23..99)*10^-5 and then we do $\simplify{{c}}$ it will be inconsistent.

Christian Lawson-Perfect

unread,
Apr 26, 2022, 8:26:11 AM4/26/22
to numbas...@googlegroups.com
Martin,
Can you give me a link to a question where this happens, please?

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/cef2a6ec-ee10-4668-9c8d-8fc906299289n%40googlegroups.com.

Ben Brawn

unread,
Apr 26, 2022, 9:04:17 AM4/26/22
to Numbas Users
While you wait for Martin's question here is what I knocked together to demonstrate https://numbas.mathcentre.ac.uk/question/share/view/6fa1be62-468e-4989-9065-28d1f81adf3d 

Martin Jones

unread,
Apr 26, 2022, 10:59:55 AM4/26/22
to Numbas Users

Christian Lawson-Perfect

unread,
Apr 28, 2022, 7:39:29 AM4/28/22
to numbas...@googlegroups.com
Thanks Martin, that helped me pin down what was happening. I've made a change that should make it consistent, and not use scientific notation when subbing into a \simplify{} command. We'll see if that has any other side-effects!

Reply all
Reply to author
Forward
0 new messages