As JdeBP is trying to hint, when you run your program from a shell and it is killed by the signal SIGFPE, the specific message "Floating point exception" is printed by your shell. Technically your program could catch the signal and print an error if you wrote it that way - but that wouldn't work for SIGKILL.
You need some parent process which uses
wait() or similar, to read the exit status of your program and log about it. The
systemd service manager is such a parent. Its message will not look identical, but it should have something equivalent when you look at the service's logs in the journal. It might mention
Additionally, if you have
systemd-coredump enabled, it should hopefully log a crash message for
SIGFPE, since the default action of this signal is to generate a core dump. These crash messages should be tagged such that they show up when querying your service's messages. I like
systemd-coredump and make sure to enable it on my Debian systems, although currently installing it will remove Apport, the crash reporter on Ubuntu. When developing, some people might prefer to deal with core files directly and not use
systemd-coredump, although it's sort of nice that the core dumps won't clutter your directory, plus they will be cleaned up after a while (freeing the disk space).