Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,14 +0,0 @@
|
|||
with Ada.Text_IO;
|
||||
procedure Numbers is
|
||||
package Int_IO is new Ada.Text_IO.Integer_IO (Integer);
|
||||
package Float_IO is new Ada.Text_IO.Float_IO (Float);
|
||||
begin
|
||||
Int_IO.Put (Integer'Value ("16#ABCF123#"));
|
||||
Ada.Text_IO.New_Line;
|
||||
Int_IO.Put (Integer'Value ("8#7651#"));
|
||||
Ada.Text_IO.New_Line;
|
||||
Int_IO.Put (Integer'Value ("2#1010011010#"));
|
||||
Ada.Text_IO.New_Line;
|
||||
Float_IO.Put (Float'Value ("16#F.FF#E+2"));
|
||||
Ada.Text_IO.New_Line;
|
||||
end Numbers;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
print to :integer "10" ; 10
|
||||
|
||||
print from.hex "10" ; 16
|
||||
print from.octal "120" ; 80
|
||||
print from.binary "10101" ; 21
|
||||
print 0x10 ; 16
|
||||
print 0o120 ; 80
|
||||
print 0b10101 ; 21
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
(phixonline)-->
|
||||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">to_integer</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"1234"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- 1234</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">to_integer</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"10101010"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- 170, 0 on failure</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">to_number</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"FFFFFFFF"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"?"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">16</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- 4294967295.0, "?" on failure</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">scanf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"#FFFFFFFF"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%f"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- <nowiki>{{</nowiki>4294967295.0<nowiki>}}</nowiki>, {} on failure</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">scanf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"0o377"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%o"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- <nowiki>{{</nowiki>255<nowiki>}}</nowiki></span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">scanf</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"1234"</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%d"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- <nowiki>{{</nowiki>1234<nowiki>}}</nowiki></span>
|
||||
<span style="color: #008080;">include</span> <span style="color: #004080;">mpfr</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
|
||||
<span style="color: #004080;">mpz</span> <span style="color: #000000;">z</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mpz_init</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #7060A8;">mpz_set_str</span><span style="color: #0000FF;">(</span><span style="color: #000000;">z</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"377"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">8</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">mpz_get_str</span><span style="color: #0000FF;">(</span><span style="color: #000000;">z</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- "255"</span>
|
||||
<span style="color: #004080;">mpfr</span> <span style="color: #000000;">f</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mpfr_init</span><span style="color: #0000FF;">()</span>
|
||||
<span style="color: #7060A8;">mpfr_set_str</span><span style="color: #0000FF;">(</span><span style="color: #000000;">f</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"110.01"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #0000FF;">?</span><span style="color: #7060A8;">mpfr_get_fixed</span><span style="color: #0000FF;">(</span><span style="color: #000000;">f</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- "6.25" (which is correct in decimal)</span>
|
||||
<!--
|
||||
with javascript_semantics
|
||||
?to_integer("1234") -- 1234
|
||||
?to_integer("10101010",0,2) -- 170, 0 on failure
|
||||
?to_number("FFFFFFFF","?",16) -- 4294967295.0, "?" on failure
|
||||
?scanf("#FFFFFFFF","%f") -- {{4294967295.0}}, {} on failure
|
||||
?scanf("0o377","%o") -- {{255}}
|
||||
?scanf("1234","%d") -- {{1234}}
|
||||
include mpfr.e
|
||||
mpz z = mpz_init()
|
||||
mpz_set_str(z,"377",8)
|
||||
?mpz_get_str(z) -- "255"
|
||||
mpfr f = mpfr_init()
|
||||
mpfr_set_str(f,"110.01",2)
|
||||
?mpfr_get_fixed(f) -- "6.25" (which is correct in decimal)
|
||||
|
|
|
|||
|
|
@ -1,79 +0,0 @@
|
|||
function Select-NumberFromString
|
||||
{
|
||||
[CmdletBinding(DefaultParameterSetName="Decimal")]
|
||||
[OutputType([PSCustomObject])]
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true,
|
||||
ValueFromPipeline=$true,
|
||||
ValueFromPipelineByPropertyName=$true,
|
||||
Position=0)]
|
||||
[string]
|
||||
$InputObject,
|
||||
|
||||
[Parameter(ParameterSetName="Decimal")]
|
||||
[Alias("d","Dec")]
|
||||
[switch]
|
||||
$Decimal,
|
||||
|
||||
[Parameter(ParameterSetName="Hexadecimal")]
|
||||
[Alias("h","Hex")]
|
||||
[switch]
|
||||
$Hexadecimal,
|
||||
|
||||
[Parameter(ParameterSetName="Octal")]
|
||||
[Alias("o","Oct")]
|
||||
[switch]
|
||||
$Octal,
|
||||
|
||||
[Parameter(ParameterSetName="Binary")]
|
||||
[Alias("b","Bin")]
|
||||
[switch]
|
||||
$Binary
|
||||
)
|
||||
|
||||
Begin
|
||||
{
|
||||
switch ($PSCmdlet.ParameterSetName)
|
||||
{
|
||||
"Decimal" {$base = 10; $pattern = '[+-]?\b[0-9]+\b'; break}
|
||||
"Hexadecimal" {$base = 16; $pattern = '\b[0-9A-F]+\b' ; break}
|
||||
"Octal" {$base = 8; $pattern = '\b[0-7]+\b' ; break}
|
||||
"Binary" {$base = 2; $pattern = '\b[01]+\b' ; break}
|
||||
"Default" {$base = 10; $pattern = '[+-]?\b[0-9]+\b'; break}
|
||||
}
|
||||
}
|
||||
Process
|
||||
{
|
||||
foreach ($object in $InputObject)
|
||||
{
|
||||
if ($object -match $pattern)
|
||||
{
|
||||
$string = $Matches[0]
|
||||
}
|
||||
else
|
||||
{
|
||||
$string = $null
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
$value = [Convert]::ToInt32($string, $base)
|
||||
}
|
||||
catch
|
||||
{
|
||||
$value = $null
|
||||
}
|
||||
|
||||
[PSCustomObject]@{
|
||||
Number = $value
|
||||
String = $string
|
||||
Base = $base
|
||||
IsNumber = $value -is [int]
|
||||
InputString = $object
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
$file = @'
|
||||
John Doe abc1 K2hdystkrs
|
||||
Jane Doe xyz2 Ew3jtdkufy
|
||||
Joe Blow def3 Ouy1ttluyl
|
||||
'@ -split [Environment]::NewLine
|
||||
|
||||
$file | Select-NumberFromString -Hexadecimal | Format-Table
|
||||
Loading…
Add table
Add a link
Reference in a new issue