Skip to content

add a few macros and functions #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

FAReTek1
Copy link

This pr just adds a few macros/functions that i thought would be useful

  • zfill from python in string.gs - just pad in 0s to the front of a string until it's the given width
  • logb - log with base - not sure which way to put parameters
  • sign macro, (x > 0 - x < 0)
  • atan2, taken from wikipedia
  • dir macro, which is similar to the point to x/y from one of the recipes
  • i added these to the testing project, although there are some false 'positives' due to floating point error

'too simple'
@FAReTek1
Copy link
Author

i removed it then

@FAReTek1 FAReTek1 requested a review from aspizu March 26, 2025 17:44
@FAReTek1
Copy link
Author

FAReTek1 commented Apr 6, 2025

bump

test/test.gs Outdated
ASSERT_EQ(LOGB(8, 2), 3, "LOGB(8, 2)")
ASSERT_EQ(SIGN(123), 1, "SIGN(123)")
ASSERT_EQ(SIGN(0), 0, "SIGN(0)")
ASSERT_EQ(SIGN(-456), 1, "SIGN(-456)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be -1?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

last one should be. ill change it

@FAReTek1
Copy link
Author

FAReTek1 commented Apr 7, 2025

I now realise that making a pull request means that one should check through the code for obvious mistakes. i found another issue where the logb macro was tested, but it was previously removed, for example.

i have checked through all the code. I think that I tested it at the time. However, due to floating point error, the test script might not be fully accurate. maybe a rounding to ~3dp would be ideal

@FAReTek1 FAReTek1 requested a review from aspizu April 7, 2025 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants