Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
- Java
- Java
- Java
- Java
- Pascal
- Ada
- C
- C
- Clojure
- Clojure
- C++
- C++
- C++
- C++
- C#
- C#
- D
- Dart
- Elixir
- Erlang
- Fortran
- Go
- Go
- Groovy
- Haskell
- JS
- JS
- JS
- Kotlin
- Kotlin
- Lisp
- Lua
- Obj-C
- PHP
- Perl
- Python
- Ruby
- Rust
- Rust
- Rust
- Scala
- Scheme
- Smalltalk
- VB
int i = new Integer(s).intValue();
Throws NumberFormatException if s does not contain a parsable integer
int i = s.chars()
.map(x -> x - '0')
.reduce((a, b) -> (a * 10) + b)
.getAsInt();
int i = Integer.parseInt(s);
Throws NumberFormatException if s does not contain a parsable integer
I : Integer := Integer'Value (s);
i = (int)strtol(s, (char **)NULL, 10);
The atoi() function has been deprecated by strtol()
(def i (Integer. s))
std::string s("123");
int i;
std::from_chars(s.data(), s.data() + s.size(), i, 10);
var i = int.parse(s);
i = String.to_integer(s)
I = list_to_integer(S).
read (unit=s,fmt=*) i
let i = read s :: Integer
const i = +s
const i = Number(s);
(setf i (parse-integer s))
i = tonumber(s)
$i = intval($s, 10);
my $i = $s + 0;
Perl automatically converts numbers to strings, and strings to numbers, whenever required. This means the addition of 0 is strictly superfluous, it only indicates programmer intent.
+ always is addition, not concatenation.
+ always is addition, not concatenation.
s.toInt
(define i (string->number s))
i := s asInteger.
Dim myint As Integer = CInt(("123"))