t-rex 4.0.0 → 4.1.0
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.
- checksums.yaml +4 -4
- data/bin/t-rex +48 -6
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b14d079aa5d64b81dd2396ae94afd0cb15c895edd5c0975f2908002b8932b6dc
|
|
4
|
+
data.tar.gz: 6101a4272e16c24e8e045056d8082b0296930684dfa66a8721f18448e2b6c7a3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 686b3b23fc583a66327627a33488681d2e4c9a5807acddbcb69604eb485a239b90b6b2bab9729a3e57074a9a6175f64f29e32552b741cd89c4f3a8f51c8897ec
|
|
7
|
+
data.tar.gz: ca87a5422e35ecdbd78a3bf1713c5ad496c4a0a0d1752bb8412afd899b02571faeb1e39335892544838379f11351206eed6f4844ff781c9ca5521d74ce24309b
|
data/bin/t-rex
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# for any damages resulting from its use. Further, I am under no
|
|
13
13
|
# obligation to maintain or extend this software. It is provided
|
|
14
14
|
# on an 'as is' basis without any expressed or implied warranty.
|
|
15
|
-
@version = "4.
|
|
15
|
+
@version = "4.1.0" # Add ENG (engineering notation) mode with Ctrl+E toggle
|
|
16
16
|
|
|
17
17
|
require 'rcurses'
|
|
18
18
|
include Rcurses::Input
|
|
@@ -81,8 +81,11 @@ help = <<HELPTEXT
|
|
|
81
81
|
R-P: X value in x, Y in y - yields "θ" in y and "r" in x.
|
|
82
82
|
P-R: "θ" in y and "r" in x - yields X in x and Y in y.
|
|
83
83
|
|
|
84
|
-
Use the "f" key to set the fixed number of decimal places. Use the "s" key to set
|
|
84
|
+
Use the "f" key to set the fixed number of decimal places. Use the "s" key to set
|
|
85
85
|
the limit for viewing numbers in the "scientific" notation (e.g. 5e+06 for 5000000).
|
|
86
|
+
|
|
87
|
+
Toggle "ENG" (engineering notation) mode with Ctrl+E. In ENG mode, exponents are
|
|
88
|
+
always multiples of 3 (e.g. 1230 becomes 1.2300e+003, 0.0045 becomes 4.5000e-003).
|
|
86
89
|
|
|
87
90
|
Content of registers #0-#9 are shown below the functions.
|
|
88
91
|
Store/recall using capital "S"/"R". "M" clears the regs.
|
|
@@ -482,9 +485,10 @@ end
|
|
|
482
485
|
|
|
483
486
|
begin # BASIC setup
|
|
484
487
|
@stk = Stack.new(0, 0, 0, 0, 0)
|
|
485
|
-
@reg = %w[0 0 0 0 0 0 0 0 0 0]
|
|
488
|
+
@reg = %w[0 0 0 0 0 0 0 0 0 0]
|
|
486
489
|
@fix = 4
|
|
487
490
|
@sci = 6
|
|
491
|
+
@eng = false
|
|
488
492
|
@dot = true
|
|
489
493
|
@mod = "Deg"
|
|
490
494
|
@hlp = true
|
|
@@ -570,7 +574,38 @@ def histprint
|
|
|
570
574
|
return print
|
|
571
575
|
end
|
|
572
576
|
def num_format(n) # THE NUMBER FORMAT FUNCTION
|
|
573
|
-
if
|
|
577
|
+
if @eng
|
|
578
|
+
# Engineering notation: exponents are multiples of 3
|
|
579
|
+
return "0" if n == 0
|
|
580
|
+
sign = n < 0 ? "-" : ""
|
|
581
|
+
n_abs = n.abs
|
|
582
|
+
|
|
583
|
+
# Calculate the exponent
|
|
584
|
+
exponent = Math.log10(n_abs).floor
|
|
585
|
+
|
|
586
|
+
# Adjust to nearest multiple of 3 (down)
|
|
587
|
+
eng_exp = (exponent / 3).floor * 3
|
|
588
|
+
|
|
589
|
+
# Calculate mantissa
|
|
590
|
+
mantissa = n_abs / (10 ** eng_exp)
|
|
591
|
+
|
|
592
|
+
# Format mantissa with appropriate decimal places
|
|
593
|
+
mantissa_str = "%.#{@fix}f" % mantissa
|
|
594
|
+
|
|
595
|
+
# Format with e notation
|
|
596
|
+
if eng_exp == 0
|
|
597
|
+
result = "#{sign}#{mantissa_str}"
|
|
598
|
+
else
|
|
599
|
+
result = "#{sign}#{mantissa_str}e%+03d" % eng_exp
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
# Apply locale formatting if needed
|
|
603
|
+
if not @dot
|
|
604
|
+
result.sub!(/\./, ',')
|
|
605
|
+
end
|
|
606
|
+
|
|
607
|
+
return result
|
|
608
|
+
elsif n.abs >= 10 ** @sci.to_i
|
|
574
609
|
n = "%.#{@sci}g" % n
|
|
575
610
|
elsif n.abs <= 10 ** (1 / @sci.to_i) and n > 10
|
|
576
611
|
n = "%.#{@sci}g" % n
|
|
@@ -806,6 +841,10 @@ def main_getkey(c) # GET KEY FROM USER
|
|
|
806
841
|
@fix = f.to_i
|
|
807
842
|
end
|
|
808
843
|
history("Fix #{f}")
|
|
844
|
+
when 'C-E' # Toggle ENG mode
|
|
845
|
+
@eng = !@eng
|
|
846
|
+
mode = @eng ? "ON" : "OFF"
|
|
847
|
+
history("ENG #{mode}")
|
|
809
848
|
when 'u' # Undo
|
|
810
849
|
unless @u.empty?
|
|
811
850
|
@stk = @u.last.dup
|
|
@@ -1402,11 +1441,13 @@ end
|
|
|
1402
1441
|
def conf_write # WRITE TO .t-rex.conf
|
|
1403
1442
|
conf = "@fix = #{@fix}\n"
|
|
1404
1443
|
conf += "@sci = #{@sci}\n"
|
|
1444
|
+
@eng ? e = "true" : e = "false"
|
|
1445
|
+
conf += "@eng = #{e}\n"
|
|
1405
1446
|
@dot ? d = "true" : d = "false"
|
|
1406
1447
|
conf += "@dot = #{d}\n"
|
|
1407
1448
|
conf += "@mod = \"#{@mod}\"\n"
|
|
1408
1449
|
conf += "@stk = Stack.new(#{@stk.x}, #{@stk.y}, #{@stk.z}, #{@stk.t}, #{@stk.l})\n"
|
|
1409
|
-
conf += "@reg = %w[#{@reg[0]} #{@reg[1]} #{@reg[2]} #{@reg[3]} #{@reg[4]} #{@reg[5]} #{@reg[6]} #{@reg[7]} #{@reg[8]} #{@reg[9]}]\n"
|
|
1450
|
+
conf += "@reg = %w[#{@reg[0]} #{@reg[1]} #{@reg[2]} #{@reg[3]} #{@reg[4]} #{@reg[5]} #{@reg[6]} #{@reg[7]} #{@reg[8]} #{@reg[9]}]\n"
|
|
1410
1451
|
@hlp ? h = "true" : h = "false"
|
|
1411
1452
|
conf += "@hlp = #{h}\n"
|
|
1412
1453
|
File.write(Dir.home+'/.t-rex.conf', conf)
|
|
@@ -1419,7 +1460,8 @@ refresh
|
|
|
1419
1460
|
Rcurses::Cursor.hide
|
|
1420
1461
|
begin # Capture main loop
|
|
1421
1462
|
loop do # Main loop
|
|
1422
|
-
|
|
1463
|
+
eng_status = @eng ? "ENG" : ""
|
|
1464
|
+
@p_inf.say(" #{@xrpn.mode_display} #{@mod} #{eng_status} Sci=#{@sci} Fix=#{@fix}".i)
|
|
1423
1465
|
pstack
|
|
1424
1466
|
pregs
|
|
1425
1467
|
@t = @stk.dup
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: t-rex
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Geir Isene
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-
|
|
11
|
+
date: 2025-10-21 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rcurses
|
|
@@ -40,8 +40,8 @@ dependencies:
|
|
|
40
40
|
version: '3.0'
|
|
41
41
|
description: 'This is a terminal curses RPN calculator similar to the traditional
|
|
42
42
|
calculators from Hewlett Packard. See https://www.hpmuseum.org/rpn.htm for info
|
|
43
|
-
on RPN (Reverse Polish Notation). Version 4.
|
|
44
|
-
|
|
43
|
+
on RPN (Reverse Polish Notation). Version 4.1.0: Add ENG (engineering notation)
|
|
44
|
+
mode with Ctrl+E toggle - exponents always multiples of 3.'
|
|
45
45
|
email: g@isene.com
|
|
46
46
|
executables:
|
|
47
47
|
- t-rex
|