varvaripfloatboolcolorstring float 用于显式声明变量或参数的“float”(浮点)类型的关键字。 例子 // float float f = 3.14 // Same as `f = 3.14` f := na plot(f) 备注 在变量声明中明确提及类型是可选的,除非它是用na初始化的。 另见 varvaripintboolcolorstring string 用于显式声明变量或参数的...
pine // Switch using an expression string i_maType = input.string("EMA", "MA type", options = ["EMA", "SMA", "RMA", "WMA"]) float ma = switch i_maType "EMA" => ta.ema(close, 10) "SMA" => ta.sma(close, 10) "RMA" => ta.rma(close, 10) // Default used when the ...
() const override; virtual std::string to_string() const override; virtual gc_ptr<value> convert(int type) const override; virtual gc_ptr<value> operator>(const value &val) const override; virtual gc_ptr<value> operator<(const value &val) const override; virtual gc_ptr<value> operator>...
(); break; case FLOAT_T: val = new float_value(_val); break; case BOOL_T: val = new bool_value(_val); break; case CHAR_T: val = new char_value(_val); break; case STRING_T: val = new string_value(this->to_string()); break; default: CONVERT_ERROR(); break; } return ...
#pragma once #include <string> #include <unordered_map> #include "../gc_ptr.h" enum value_t { VOID_T, INT_T, FLOAT_T, CHAR_T, STRING_T, BOOL_T, ARRAY_T, NULL_T }; class value { private: static std::unordered_map<int, std::string> _name; public: static const std::string...
#pragma once #define CONVERT_ERROR() state::error((std::string) "cannot convert '" + this->type_name() + "' to '" + value::type_to_name(type) + "'") #define VALUE_IO_TEMPLATE(value_type) \ void value_type::input() \ { \ std::cin >> _val; \ } \ void value_type::...
#include "value.h" #include "temps.h" #include "../state.h" std::unordered_map<int, std::string> value::_name{{VOID_T, "void"}, {NULL_T, "null"}, {INT_T, "int"}, {FLOAT_T, "float"}, {CHAR_T, "char"}, {STRING_T, "string"}, {BOOL_T, "bool"}, {ARRAY_T, "...
() const override; virtual std::string to_string() const override; virtual gc_ptr<value> operator-() const override; virtual gc_ptr<value> convert(int type) const override; virtual gc_ptr<value> operator*(const value &val) const override; virtual gc_ptr<value> operator/(const value &...
s[1] : char_value::escape(s + 1).first; } std::string char_value::to_string() const { return std::string(&_val, 1); } gc_ptr<value> char_value::copy() const { return new char_value(_val); } gc_ptr<value> char_value::convert(int type) const { gc_ptr<value> val = ...
str.tonumber(string) 返回值 如果包含有效数字,为字符串的浮点型,否则为na。参数string (series string) int或float的字符串表现形式。str.format将格式字符串和值转换为格式化字符串。格式字符串可以包含文字文本和每个要格式化的值的大括号{}中的一个占位符。每个占位符包括将替换它的必需参数的指数(从0开始) ...