@@ -145,7 +145,7 @@ namespace StdLib
145145 Token a = tokens[0 ];
146146 Token b = tokens[1 ];
147147 if (a.getType () == TokenType::Number && b.getType () == TokenType::Number)
148- return Token (TokenType::Number, std::to_string (std::stoi (a.getValue ()) + std::stoi (b.getValue ())));
148+ return Token (TokenType::Number, std::to_string (std::stoll (a.getValue ()) + std::stoll (b.getValue ())));
149149 else {
150150 return Token (TokenType::String, a.getValue () + b.getValue ());
151151 }
@@ -154,25 +154,25 @@ namespace StdLib
154154 Token a = tokens[0 ];
155155 Token b = tokens[1 ];
156156 if (a.getType () == TokenType::Number && b.getType () == TokenType::Number)
157- return Token (TokenType::Number, std::to_string (std::stoi (a.getValue ()) - std::stoi (b.getValue ())));
157+ return Token (TokenType::Number, std::to_string (std::stoll (a.getValue ()) - std::stoll (b.getValue ())));
158158 }
159159 Token f_mul (const std::vector<Token> tokens) {
160160 Token a = tokens[0 ];
161161 Token b = tokens[1 ];
162162 if (a.getType () == TokenType::Number && b.getType () == TokenType::Number)
163- return Token (TokenType::Number, std::to_string ((int )(std::stod (a.getValue ()) * std::stod (b.getValue ()))));
163+ return Token (TokenType::Number, std::to_string ((long long int )(std::stod (a.getValue ()) * std::stod (b.getValue ()))));
164164 }
165165 Token f_div (const std::vector<Token> tokens) {
166166 Token a = tokens[0 ];
167167 Token b = tokens[1 ];
168168 if (a.getType () == TokenType::Number && b.getType () == TokenType::Number)
169- return Token (TokenType::Number, std::to_string ((int )std::stod (a.getValue ()) / std::stod (b.getValue ())));
169+ return Token (TokenType::Number, std::to_string ((long long int )std::stod (a.getValue ()) / std::stod (b.getValue ())));
170170 }
171171 Token f_mod (const std::vector<Token> tokens) {
172172 Token a = tokens[0 ];
173173 Token b = tokens[1 ];
174174 if (a.getType () == TokenType::Number && b.getType () == TokenType::Number)
175- return Token (TokenType::Number, std::to_string (std::stoi (a.getValue ()) % std::stoi (b.getValue ())));
175+ return Token (TokenType::Number, std::to_string (std::stoll (a.getValue ()) % std::stoll (b.getValue ())));
176176 }
177177 Token f_not (const std::vector<Token> tokens) {
178178 Token a = tokens[0 ];
@@ -271,6 +271,10 @@ namespace StdLib
271271 std::uniform_real_distribution<double > unif (0 , 1 );
272272 return Token (TokenType::Number, std::to_string (unif (rng)));
273273 }
274+ Token f_time (const std::vector<Token> tokens) {
275+ std::string retTime = std::to_string (std::chrono::system_clock::now ().time_since_epoch () / std::chrono::milliseconds (1 ));
276+ return Token (TokenType::Number, retTime);
277+ }
274278 Token f_split (const std::vector<Token> tokens) {
275279 Token saveTo = tokens[0 ];
276280 Token string = tokens[1 ];
@@ -322,6 +326,7 @@ namespace StdLib
322326 f (" string" , f_string, 1 ),
323327 f (" int" , f_int, 1 ),
324328 f (" random" , f_random, 0 ),
329+ f (" time" , f_time, 0 ),
325330 f (" split" , f_split, 3 ),
326331 };
327332
0 commit comments