Logo

Programming-Idioms

Create an object x to store n bits (n being potentially large).
Implementation
Pascal

Implementation edit is for fixing errors and enhancing with metadata. Please do not replace the code below with a different implementation.

Instead of changing the code of the snippet, consider creating another Pascal implementation.

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.

Other implementations
import java.util.BitSet;
BitSet x = new BitSet(n);
import "math/big"
var x *big.Int = new(big.Int)
vec($x, $n, 1) = 0;
import std.bitmanip;
BitArray x;
x.length = n;
procedure Task;
var
  x: Set Of Byte;
begin
  x:= [2,4,8,16,32,64,256];  
end;
import Data.Bits
x :: Integer
x = sum [bit i | i <- [1..n], wannaset i]
$x = new BitSet($n);
#include <vector>
std::vector<bool> x(n, 0);
from __future__ import division
import math
x = bytearray(int(math.ceil(n / 8.0)))
let mut x = vec![false; n];
let x = new Buffer (Math.ceil (n / 8))
x = 0
using System.Collections;
new BitArray(n);
x := make([]bool, n)
x := make([]uint64, (n+63)/64)
#include <bitset>
std::bitset<n> x;
(let ((x (make-array n :element-type 'bit))))
import 'package:bit_array/bit_array.dart';
final x = FixedBitArray(n);