gavinhoward / bc

An implementation of the POSIX bc calculator with GNU extensions and dc, moved away from GitHub. Finished, but well-maintained.
https://git.gavinhoward.com/gavin/bc
Other
145 stars 29 forks source link

Command switch for scale? #47

Closed depler closed 2 years ago

depler commented 2 years ago

Is there any command line switch to set scale at start, like bc.exe --scale 100? If not, could you please implement?

gavinhoward commented 2 years ago

There is no direct way to do it, but you can do it like this:

bc.exe -e "scale = 100" -f-

-e is the command-line option to take expressions, and since bc exits by default when giving it an expression, you add -f- to tell it to also accept input from stdin.

I think next release, I will add the ability to not exit by default on expressions for Windows. (FreeBSD wants my bc to exit by default.) Once I do that, you will be able to do:

bc.exe -e "scale = 100"
depler commented 2 years ago

Well, this is not really an option for me - I want bc to exit after -e switch. The point is to have ability to manipulate of scale value from outside - the only option for now to do it is within a script or command. Anyway, not really a problem. Fell free to close this, if you are not going implement scale switch.

gavinhoward commented 2 years ago

Yeah, I'm sorry. It's a little too specialized to do in my opinion.

Thank you for understanding.

gavinhoward commented 2 years ago

@depler would you still want this? I'm going to do a release soon, and I'm reconsidering it.

gavinhoward commented 2 years ago

@depler I'm going to implement this.

gavinhoward commented 2 years ago

It is now implemented in 488d48c87c5b9e02e5c3911918c2d6d7687246e8. The command-line options are -S/--scale, -I/--ibase, -O/--obase, and -E/--seed.

If you could test before I release 5.3.0, I would appreciate it.

Also, history is working on Windows now!

gavinhoward commented 2 years ago

It's been released in 5.3.0. Hope this helps!