Numeric separator syntax: Difference between revisions

added ocaml
(added ocaml)
Line 124:
ERROR: UndefVarError: __000__000 not defined
</lang>
 
=={{header|OCaml}}==
Underscores can be used as separators in integer or floating-point literals, and they are ignored. Underscores can be in any position except at the beginning, and you can use consecutive underscores.
<lang ocaml>Printf.printf "%d\n" 1_2_3;; (* 123 *)
Printf.printf "%d\n" 0b1_0_1_0_1;; (* 21 *)
Printf.printf "%d\n" 0xa_bc_d;; (* 43981 *)
Printf.printf "%d\n" 12__34;; (* 1234 *)
Printf.printf "%f\n" 1_2_3_4.2_5;; (* 1234.250000 *)
Printf.printf "%f\n" 6.0_22e4;; (* 60220.000000 *)
Printf.printf "%f\n" 1234_.25;; (* 1234.250000 *)
Printf.printf "%f\n" 1234._25;; (* 1234.250000 *)
Printf.printf "%f\n" 1234.25_;; (* 1234.250000 *)</lang>
 
=={{header|Perl}}==
Anonymous user