Skip to content

Main content

Random Octal Value Generator Source Code

Browse the implementation files for Random Octal Value Generator.
@tool.io/tools/random/number source ↗
tool.ts typescript
import type { RandomSource } from '@tool.io/tools/random/number';
import { randomRadixValue } from '../radix-value/tool';

export const randomOctal = (
	minimum: unknown,
	maximum: unknown,
	width: unknown,
	prefix: unknown,
	random: RandomSource = Math.random
): string =>
	randomRadixValue(minimum, maximum, width, prefix, 8, random);

export const Tool: TypeTool = {
	name: 'Random Octal Value Generator',
	slug: 'random/octal',
	intro:
		'Generate a random nonnegative integer formatted in base 8.',
	tool: randomOctal,
	i: [
		{
			example: '0',
			label: 'Minimum',
			placeholder: 'Minimum integer',
			type: 'number',
			value: '0'
		},
		{
			example: '511',
			label: 'Maximum',
			placeholder: 'Maximum integer',
			type: 'number',
			value: '511'
		},
		{
			example: '3',
			label: 'Minimum width',
			placeholder: 'Octal digits',
			type: 'number',
			value: '3'
		},
		{
			example: 'include',
			label: 'Prefix',
			placeholder: 'Prefix',
			type: 'select',
			value: 'include',
			options: [
				{
					value: 'include',
					text: 'Include 0o',
					selected: true
				},
				{ value: 'none', text: 'No prefix' }
			]
		}
	],
	o: [
		{
			example: '0o052',
			label: 'Random octal value',
			placeholder: 'Random octal value',
			render: 'textarea',
			type: 'text'
		}
	],
	rerunnable: true,
	alternative: [
		{ title: 'Random Binary Value', url: '/random/binary' },
		{
			title: 'Random Hexadecimal Value',
			url: '/random/hexadecimal'
		},
		{ title: 'Random Number', url: '/random/number' }
	],
	cite: [
		{
			title: 'Octal - Wikipedia',
			url: 'https://en.wikipedia.org/wiki/Octal'
		}
	]
};

export default Tool;

Description

Browse the implementation files for Random Octal Value Generator.

References

  1. Tool.io on GitHub
  2. Tool.io TypeScript tools library

Similar or alternative tools