rpl.rb/lib/core/mode.rb
Gwenhael Le Moine 8c5657db42
big refactoring
2022-02-08 15:45:36 +01:00

35 lines
786 B
Ruby

# frozen_string_literal: true
module Rpl
module Lang
module Core
module_function
# set float precision in bits. ex: 256 prec
def prec( stack, dictionary )
stack, args = Rpl::Lang.stack_extract( stack, [%i[numeric]] )
Rpl::Lang.precision = args[0][:value]
[stack, dictionary]
end
# set float representation and precision to default
def default( stack, dictionary )
Rpl::Lang.precision = 12
[stack, dictionary]
end
# show type of stack first entry
def type( stack, dictionary )
stack, args = Rpl::Lang.stack_extract( stack, [:any] )
stack << { type: :string,
value: args[0][:type].to_s }
[stack, dictionary]
end
end
end
end