Bug with Mod?

Bug with Mod? - Messages

#1 Posted: 1/1/2021 11:11:36 AM
overlord

overlord

547 likes in 1330 posts.

Group: Moderator

I had encountered a strange behavior while trying to implement Tupper Formula.
Is this a bug or SMath shouldn't calculate modular of such a long number?
Sorry for very big picture but don't know how to show it in here else.
Build 0.99.7666 on Linux, same result with previous old builds by the way.

Regards

tupper.sm (4 KiB) downloaded 23 time(s).

2021-01-01_17-10.png
#2 Posted: 1/1/2021 1:54:02 PM
Martin Kraska

Martin Kraska

1222 likes in 2150 posts.

Group: Moderator

SMath doesn't have exact integer arithmetics. Numbers are handled as floats with finite precision. You will find that k+1=k evaluates to true. If you want to do exact integer arithmetics, Unfortunately, you can't even use CAS plugins like maxima or maple because any input is handled by SMath first before conveying it to the plugin. This includes downgrading of numeric constants to IEEE 754 floats.

Maxima has a mechanism of using string input to circumvent this but this will look extremly ugly in the SMath sheet.

tupper_kr.sm (4 KiB) downloaded 23 time(s).
2021-01-01 17_52_19-SMath Studio - [tupper.sm_].png
Martin Kraska Pre-configured portable distribution of SMath Studio: https://en.smath.info/wiki/SMath%20with%20Plugins.ashx
#3 Posted: 1/1/2021 7:20:14 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Is this a bug or SMath shouldn't calculate modular of such a long number?


"modular" ... you mean 'mod'
Write ... mod(k,1.23456789)
Write ... mod(k,123456789.987654321)
#4 Posted: 1/2/2021 10:51:59 AM
overlord

overlord

547 likes in 1330 posts.

Group: Moderator

Wrote

SMath doesn't have exact integer arithmetics. Numbers are handled as floats with finite precision.


Thanks Martin, I figured so.
This is why there is a question, "bug or not".
Clearly it is not a bug but how SMath works.

Regards


#5 Posted: 1/2/2021 8:08:42 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

This is why there is a question, "bug or not".


Nothing new here. I posted the attached long time ago, no answer.
Too big numbers chokes Smath.

Critical error.sm (2 KiB) downloaded 20 time(s).
  • New Posts New Posts
  • No New Posts No New Posts