rpl.rb/lib/core/mode.rb

36 lines
786 B
Ruby
Raw Normal View History

2021-12-07 16:09:17 +01:00
# frozen_string_literal: true
module Rpl
2021-12-07 15:50:58 +01:00
module Lang
module Core
module_function
2021-12-07 15:50:58 +01:00
# set float precision in bits. ex: 256 prec
def prec( stack, dictionary )
2022-02-08 15:45:36 +01:00
stack, args = Rpl::Lang.stack_extract( stack, [%i[numeric]] )
2022-02-08 15:45:36 +01:00
Rpl::Lang.precision = args[0][:value]
[stack, dictionary]
2021-12-07 15:50:58 +01:00
end
2021-12-07 15:50:58 +01:00
# set float representation and precision to default
def default( stack, dictionary )
2022-02-08 15:45:36 +01:00
Rpl::Lang.precision = 12
[stack, dictionary]
2021-12-07 15:50:58 +01:00
end
2021-12-07 15:50:58 +01:00
# show type of stack first entry
def type( stack, dictionary )
2022-02-08 15:45:36 +01:00
stack, args = Rpl::Lang.stack_extract( stack, [:any] )
2021-12-07 15:50:58 +01:00
stack << { type: :string,
value: args[0][:type].to_s }
[stack, dictionary]
2021-12-07 15:50:58 +01:00
end
end
end
end