Skip to content
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

Math Parser Idea: e(value,n) #433

Open
Reptorian1125 opened this issue Oct 8, 2024 · 3 comments
Open

Math Parser Idea: e(value,n) #433

Reptorian1125 opened this issue Oct 8, 2024 · 3 comments

Comments

@Reptorian1125
Copy link

Reptorian1125 commented Oct 8, 2024

There are sometimes when I had to use a workaround to the fact that you cannot place variables next to e. 2.4e$var isn't allowed.

foo:
m=3
eval "2.5e$m;"

This will give a error.

So, one way of solving it is e(value,n). Which is the equivalent of {value}e{n} where value, and n is a number. Or maybe unnecessary, and there should be some fixes to the parsing of 2.5e$m.

EDIT: {value}*10^{n} will do too, but ideally I would like to see better parsing.

@dtschump
Copy link
Collaborator

Variable are not substituted when inside double-quotes, so you have to move them outside double quotes, like this:

foo:
  m=3
  eval "2.5e"$m";"

@Reptorian1125
Copy link
Author

Yes, I know.

I thought it was possible with 0b, and 0x. I checked, and it turns out they only work with $1,$-1.

In Lavender Binary Map case:

		const first_binary_to_search=0b$3;
		const second_binary_to_search=0b$4;

That does work.

@dtschump
Copy link
Collaborator

Yes, that's because $1 is actually not a variable, it's a command argument, which is quite different (even if the syntax is similar).

  • A command argument as $1 is indeed substituted inside double-quoted strings.
  • A variable as $foo is not.

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

No branches or pull requests

2 participants