s-macke / jor1k

Online OR1K Emulator running Linux
http://jor1k.com
BSD 2-Clause "Simplified" License
1.73k stars 193 forks source link

Cosine function in bc returns void result when executing a script #147

Closed tiborbaksa closed 3 years ago

tiborbaksa commented 5 years ago

Steps to reproduce

  1. Create a file called test.bc with the following content

    print "sin 0.1 = ", s(0.1), "\n"
    print "cos 0.1 = ", c(0.1), "\n"
  2. Execute the following command

    bc -lq test.bc

Expected result

sin 0.1 = .09983341664682815230
cos 0.1 = .99500416527802576609

Actual result

sin 0.1 = .09983341664682815230
test.bc 2: void expression in print

Workaround

Direct the contents of the script into bc instead of pass by parameter:

$ bc -lq < test.bc
sin 0.1 = .09983341664682815230
cos 0.1 = .99500416527802576609

Other information

As shown by the workaround, the cosine function does work as expected when bc does not execute a script. However it cannot be used when bc executes a script even after the execution finished.

The same issue can be observed when using the Bessel function j(n,x).

The same version of bc does not have the same issue on other platforms, I tried with JSLinux.

I'm not sure if this is an issue with the bc OpenRISC port or the emulator.

This was not an issue on the 3rd of July, 2013 as shown in this forum thread (in Hungarian). The linked script uses both the sine and cosine functions in line 12 and it could be executed with bc without any issues.

tiborbaksa commented 3 years ago

I'm closing this issue because I cannot reproduce it anymore.