t-rex 2.1 → 2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/t-rex +8 -5
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e26ed814ef64c7de43f05514e3a9fad738f94b43279d134e021539ed2dc4a996
4
- data.tar.gz: 11f7f34f9ec6822c8520f9a9ea8b422cecf7518172fc9c02a3ec1dce8a745c24
3
+ metadata.gz: cc55f9485a29e3fbe0c29a51086e83ac0381fc221a1edb186a6282f3a56a03d4
4
+ data.tar.gz: d3e0ed8a6f61edcbfaa9228c765c545c209cbaa1714151cd5bb8ff6d6dddc262
5
5
  SHA512:
6
- metadata.gz: 54dde9c96ddb5b10b324d0c3bb2b459960a7e395550d2f1a04a0774cba06da7e404df495bd5392555c588f3aaaaf25f23a4337a9d0eeb6aa3dcebb1bc2adb98b
7
- data.tar.gz: 23cc5bad45026e181f5d95990d10bf308f029cbfec9c01fed87f95dca277dba785560d3828f5af77e7173427a6783f3547de6d6f28797925c24f3f1ab2301ccd
6
+ metadata.gz: bae00939e5215a19d75cfcfa152129785f20e47558c717236c35ca39d67e342d78033618836c2d608d351d9db2fc09f4fe9813cca7fea1a93ac954b3818178ec
7
+ data.tar.gz: 85005f785b9889b259e56d5061791c2219bc3e4c95bf9ecce60e7ed2ae69bbbdfc4723e1673e1f5284e8670d4315aa6984bb04a8819b532bce916d5aa0e2e013
data/bin/t-rex CHANGED
@@ -29,7 +29,8 @@ help = <<HELPTEXT
29
29
  Toggle US and European number formats by pressing '.
30
30
 
31
31
  When entering a number into X, use 'h' to change the sign and 'e' to write an
32
- exponent (10^x). Entering "123e4" becomes "1230000".
32
+ exponent (10^x). Entering "123e4" becomes "1230000". Use 'H' to enter a minus sign
33
+ after an 'e' to get a negative exponent. Entering "123e-4" becomes "0.0123".
33
34
 
34
35
  Functions available are shown under the stack registers. The orange symbol
35
36
  corresponds to the key to be pressed. For functions above each label (grey
@@ -635,7 +636,7 @@ def entry(chr) # X REGISTER ENTRY
635
636
  pos = 1
636
637
  Rcurses::Cursor.set(7,33)
637
638
  Rcurses::Cursor.show
638
- while %w[0 1 2 3 4 5 6 7 8 9 . , h e RIGHT LEFT HOME END DEL BACK WBACK LDEL].include?(chr)
639
+ while %w[0 1 2 3 4 5 6 7 8 9 . , h H e RIGHT LEFT HOME END DEL BACK WBACK LDEL].include?(chr)
639
640
  @p_x.puts(num)
640
641
  chr = getchr
641
642
  case chr
@@ -679,6 +680,9 @@ def entry(chr) # X REGISTER ENTRY
679
680
  num.insert(0, "-")
680
681
  pos += 1
681
682
  end
683
+ when 'H'
684
+ num.insert(pos,"-")
685
+ pos += 1
682
686
  when 'e'
683
687
  num.insert(pos,chr)
684
688
  pos += 1
@@ -691,9 +695,8 @@ def entry(chr) # X REGISTER ENTRY
691
695
  num = "" if %w[DOWN UP].include?(chr)
692
696
  num.gsub!(/,/, '.')
693
697
  if num.include?("e")
694
- n = num.split("e").first(2)
695
- n[1] = (10 ** n[1].to_i)
696
- num = n.join
698
+ base, exp_str = num.split("e")
699
+ num = (base.to_f * (10 ** exp_str.to_i)).to_s
697
700
  end
698
701
  num != "" ? number = num.to_f : number = ""
699
702
  Rcurses::Cursor.hide
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: t-rex
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.1'
4
+ version: '2.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Geir Isene
@@ -27,7 +27,8 @@ dependencies:
27
27
  description: 'This is a terminal curses RPN calculator similar to the traditional
28
28
  calculators from Hewlett Packard. See https://www.hpmuseum.org/rpn.htm for info
29
29
  on RPN (Reverse Polish Notation). New in 2.1: Added ''e'' for entering exponents
30
- directly into X.'
30
+ directly into X. 2.2: Allowing for negative exponents (use ''H'' to enter a minus
31
+ sign).'
31
32
  email: g@isene.com
32
33
  executables:
33
34
  - t-rex