Skip to content
This repository has been archived by the owner on Nov 11, 2021. It is now read-only.

Parity error between numbers in simulation and compilation #136

Open
Nabushika opened this issue Oct 12, 2021 · 1 comment
Open

Parity error between numbers in simulation and compilation #136

Nabushika opened this issue Oct 12, 2021 · 1 comment

Comments

@Nabushika
Copy link

Python uses bigints by default, which means you can have arbitrarily large numbers. I noticed this when writing an abs macro. The following code produces two different outputs on my machine:

include "std.porth"
macro abs
 if dup 0 < do
   0 over - swap drop
 end
end

-18446744073709551615 abs
// becomes 1 on bare metal, 18446744073709551615 in Python
1 - 
if 0 = do
 "We're running on bare metal!\n" puts
else
 "We're in a simulation!\n" puts
end

Not sure if it's worth fixing in Python as when Porth becomes self-hosted this issue will go away.
At least it's amusing :)

@rexim
Copy link
Member

rexim commented Oct 12, 2021

@Nabushika oh yeah, that's pretty cool! 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants