Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
3
Task/Variable-size-Set/00-META.yaml
Normal file
3
Task/Variable-size-Set/00-META.yaml
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
from: http://rosettacode.org/wiki/Variable_size/Set
|
||||
note: Type System
|
||||
4
Task/Variable-size-Set/00-TASK.txt
Normal file
4
Task/Variable-size-Set/00-TASK.txt
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
;Task:
|
||||
Demonstrate how to specify the minimum size of a variable or a data type.
|
||||
<br><br>
|
||||
|
||||
25
Task/Variable-size-Set/360-Assembly/variable-size-set.360
Normal file
25
Task/Variable-size-Set/360-Assembly/variable-size-set.360
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
* Binary interger (H,F)
|
||||
I2 DS H half word 2 bytes
|
||||
I4 DS F full word 4 bytes
|
||||
* Real (floating point) (E,D,L)
|
||||
X4 DS E short 4 bytes
|
||||
X8 DS D double 8 bytes
|
||||
X16 DS L extended 16 bytes
|
||||
* Packed decimal (P)
|
||||
P3 DS PL3 2 bytes
|
||||
P7 DS PL7 4 bytes
|
||||
P15 DS PL15 8 bytes
|
||||
* Zoned decimal (Z)
|
||||
Z8 DS ZL8 8 bytes
|
||||
Z16 DS ZL16 16 bytes
|
||||
* Character (C)
|
||||
C1 DS C 1 byte
|
||||
C16 DS CL16 16 bytes
|
||||
C256 DS CL256 256 bytes
|
||||
* Bit value (B)
|
||||
B1 DC B'10101010' 1 byte
|
||||
* Hexadecimal value (X)
|
||||
X1 DC X'AA' 1 byte
|
||||
* Address value (A)
|
||||
A4 DC A(176) 4 bytes but only 3 bytes used
|
||||
* (24 bits => 16 MB of storage)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
MyByte:
|
||||
byte 0 ;most assemblers will also accept DB or DFB
|
||||
MyWord:
|
||||
word 0 ;most assemblers will also accept DW or DFW
|
||||
MyDouble:
|
||||
dd 0
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
.rsset $00 ;starting at $0400, the following labels represent sequential memory locations of length ".rs n"
|
||||
VBlankFlag .rs 1 ;$00
|
||||
soft_PPUCTRL .rs 1 ;$01
|
||||
soft_PPUSTATUS .rs 1 ;$02
|
||||
soft_SCROLL_X .rs 1 ;$03
|
||||
soft_SCROLL_Y .rs 1 ;$04
|
||||
temp_16 .rs 2 ;$05,$06
|
||||
tempStack .rs 1 ;$07
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
VBlankFlag equ $00
|
||||
soft_PPUCTRL equ $01
|
||||
soft_PPUSTATUS equ $02
|
||||
soft_SCROLL_X equ $03
|
||||
soft_SCROLL_Y equ $04
|
||||
temp_16 equ $05 ;you have to keep track of spacing yourself in this method
|
||||
tempStack equ $07
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
MyByte:
|
||||
DC.B 0
|
||||
EVEN ;you need this to prevent alignment problems if you define an odd number of bytes.
|
||||
MyWord:
|
||||
DC.W 0 ;this takes up 2 bytes even though only one 0 was written
|
||||
MyLong:
|
||||
DC.L 0 ;this takes up 4 bytes even though only one 0 was written
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Cursor_X equ $100000 ;byte - only comments can tell you the intended variable size.
|
||||
Cursor_Y equ $100001 ;byte
|
||||
tempWord equ $100002 ;word - also occupies $100003
|
||||
tempLong equ $100004 ;long - also occupies $100005,6,7
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
.data ;data segment
|
||||
|
||||
TestValue_00 byte 0 ;an 8-bit variable
|
||||
TestValue_01 word 0 ;a 16-bit variable
|
||||
TestValue_02 dword 0 ;a 32-bit variable
|
||||
|
||||
.code
|
||||
|
||||
start:
|
||||
|
||||
mov dh, byte ptr [ds:TestValue_00] ;load the value stored at the address "TestValue_00"
|
||||
mov ax, word ptr [ds:TestValue_01] ;load the value stored at the address "TestValue_01"
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
mov al, byte ptr [ds:TestValue_02]
|
||||
;even though this was listed as a dword in the data segment, the assembler lets us do this!
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
foo byte 0,0,0,0
|
||||
bar word 0,0
|
||||
baz dword 0
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
Array1 byte 00,01,02,03
|
||||
|
||||
Array2 byte 00,01
|
||||
byte 02,03
|
||||
|
|
@ -0,0 +1 @@
|
|||
BigNumber byte 256 dup (0) ;reserve 256 bytes, each equals zero
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
.byte 0xFF
|
||||
.align 4
|
||||
.word 0xFFFF
|
||||
.align 4
|
||||
.long 0xFFFFFFFF
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
main:
|
||||
ADR r1,TestData ;load the address TestData
|
||||
LDRB r0,[r1] ;loads 0x000000EF into r0 (assuming the CPU is operating as little-endian, otherwise it will load 0x000000DE)
|
||||
BX LR
|
||||
TestData:
|
||||
.long 0xDEADBEEF
|
||||
2
Task/Variable-size-Set/Ada/variable-size-set.ada
Normal file
2
Task/Variable-size-Set/Ada/variable-size-set.ada
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
type Response is (Yes, No); -- Definition of an enumeration type with two values
|
||||
for Response'Size use 1; -- Setting the size of Response to 1 bit, rather than the default single byte size
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
0 CLEAR : PRINT "DATA TYPES":F = 0:F = FRE (0)
|
||||
1 PRINT "FLOATING POINT:";:G = 0: GOSUB 9
|
||||
2 PRINT "INTEGER:";:I0% = 0: GOSUB 9
|
||||
3 PRINT "STRING:";:Z9$ = "": GOSUB 9
|
||||
4 PRINT "DEFINED-FUNCTION:";: DEF FN DO(IT) = 1 + LEN ( MID$ (Z9$,1)) + IT: GOSUB 9: PRINT
|
||||
5 PRINT "ARRAYS OF SIZE 1"
|
||||
6 PRINT "FLOATING POINT:";: DIM F(0): GOSUB 9: PRINT "INTEGER:";: DIM I%(0): GOSUB 9: PRINT "STRING:";: DIM S$(0): GOSUB 9: PRINT
|
||||
7 PRINT "ARRAYS OF SIZE 2"
|
||||
8 PRINT "FLOATING POINT:";: DIM G(1): GOSUB 9: PRINT "INTEGER:";: DIM J%(1): GOSUB 9: PRINT "STRING:";: DIM T$(1): GOSUB 9: END
|
||||
9 PRINT F - FRE (0)" ";:F = FRE (0): RETURN
|
||||
3
Task/Variable-size-Set/BASIC/variable-size-set.basic
Normal file
3
Task/Variable-size-Set/BASIC/variable-size-set.basic
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
10 DIM A%(10): REM the array size is 10 integers
|
||||
20 DIM B(10): REM the array will hold 10 floating point values
|
||||
30 DIM C$(12): REM a character array of 12 bytes
|
||||
4
Task/Variable-size-Set/BBC-BASIC/variable-size-set.basic
Normal file
4
Task/Variable-size-Set/BBC-BASIC/variable-size-set.basic
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
var& = 1 : REM Variable occupies 8 bits
|
||||
var% = 1 : REM Variable occupies 32 bits
|
||||
var = 1 : REM Variable occupies 40 bits
|
||||
var# = 1 : REM Variable occupies 64 bits
|
||||
3
Task/Variable-size-Set/C++/variable-size-set.cpp
Normal file
3
Task/Variable-size-Set/C++/variable-size-set.cpp
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#include <boost/cstdint.hpp>
|
||||
|
||||
boost::int_least32_t foo;
|
||||
3
Task/Variable-size-Set/C/variable-size-set-1.c
Normal file
3
Task/Variable-size-Set/C/variable-size-set-1.c
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#include <stdint.h>
|
||||
|
||||
int_least32_t foo;
|
||||
6
Task/Variable-size-Set/C/variable-size-set-2.c
Normal file
6
Task/Variable-size-Set/C/variable-size-set-2.c
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
union u {
|
||||
int i;
|
||||
long l;
|
||||
double d;
|
||||
/* ... */
|
||||
};
|
||||
4
Task/Variable-size-Set/C/variable-size-set-3.c
Normal file
4
Task/Variable-size-Set/C/variable-size-set-3.c
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
union must_be_at_least_512_bytes {
|
||||
int interesting_datum;
|
||||
char padding[512];
|
||||
};
|
||||
2
Task/Variable-size-Set/D/variable-size-set-1.d
Normal file
2
Task/Variable-size-Set/D/variable-size-set-1.d
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
typedef long[0] zeroLength ;
|
||||
writefln(zeroLength.sizeof) ; // print 0
|
||||
4
Task/Variable-size-Set/D/variable-size-set-2.d
Normal file
4
Task/Variable-size-Set/D/variable-size-set-2.d
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
byte b ;
|
||||
ubyte ub ;
|
||||
char c ;
|
||||
bool t ;
|
||||
2
Task/Variable-size-Set/D/variable-size-set-3.d
Normal file
2
Task/Variable-size-Set/D/variable-size-set-3.d
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
struct Empty { }
|
||||
writefln(Empty.sizeof) ; // print 1
|
||||
23
Task/Variable-size-Set/Delphi/variable-size-set.delphi
Normal file
23
Task/Variable-size-Set/Delphi/variable-size-set.delphi
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{In Delphi you can have variables of a range of sizes}
|
||||
var B: Byte; {8-bit, unsigned}
|
||||
var C: char; {ASCII character}
|
||||
var SI: shortint; {8-bit, signed}
|
||||
var SM: Smallint; {16-bit signed}
|
||||
var LI: Longint; {32-bit signed}
|
||||
var W: word; {16-bit unsigned}
|
||||
var LW: Longword; {32-bit unsigned}
|
||||
var II: Int64; {64-bit signed}
|
||||
var SR: Real48; {6-byte real}
|
||||
var SN: single; {4-byte real}
|
||||
var DB: double; {8-byte real}
|
||||
var EX: Extended; {10-byte real}
|
||||
var CM: Comp; {8-byte fixed point}
|
||||
var CR: Currency; {8-byte fixed point}
|
||||
|
||||
{You can also custom define the size range of variable}
|
||||
|
||||
type TNumRange = -128..127;
|
||||
var NM: TNumRange;
|
||||
|
||||
type TUpperCase = 'A'..'Z';
|
||||
var UP: TUpperCase;
|
||||
5
Task/Variable-size-Set/ERRE/variable-size-set.erre
Normal file
5
Task/Variable-size-Set/ERRE/variable-size-set.erre
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
DIM A%[10] ! the array size is 10 integers
|
||||
|
||||
DIM B[10] ! the array will hold 10 floating point values
|
||||
|
||||
DIM C$[12] ! a character array of 12 bytes
|
||||
43
Task/Variable-size-Set/Fortran/variable-size-set.f
Normal file
43
Task/Variable-size-Set/Fortran/variable-size-set.f
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
program setsize
|
||||
implicit none
|
||||
|
||||
integer, parameter :: p1 = 6
|
||||
integer, parameter :: p2 = 12
|
||||
integer, parameter :: r1 = 30
|
||||
integer, parameter :: r2 = 1000
|
||||
integer, parameter :: r3 = 2
|
||||
integer, parameter :: r4 = 4
|
||||
integer, parameter :: r5 = 8
|
||||
integer, parameter :: r6 = 16
|
||||
integer, parameter :: rprec1 = selected_real_kind(p1, r1)
|
||||
integer, parameter :: rprec2 = selected_real_kind(p2, r1)
|
||||
integer, parameter :: rprec3 = selected_real_kind(p2, r2)
|
||||
integer, parameter :: iprec1 = selected_int_kind(r3)
|
||||
integer, parameter :: iprec2 = selected_int_kind(r4)
|
||||
integer, parameter :: iprec3 = selected_int_kind(r5)
|
||||
integer, parameter :: iprec4 = selected_int_kind(r6)
|
||||
|
||||
real(rprec1) :: n1
|
||||
real(rprec2) :: n2
|
||||
real(rprec3) :: n3
|
||||
integer(iprec1) :: n4
|
||||
integer(iprec2) :: n5
|
||||
integer(iprec3) :: n6
|
||||
integer(iprec4) :: n7
|
||||
character(30) :: form
|
||||
|
||||
form = "(a7, i11, i10, i6, i9, i8)"
|
||||
write(*, "(a)") "KIND NAME KIND NUMBER PRECISION RANGE "
|
||||
write(*, "(a)") " min set min set"
|
||||
write(*, "(a)") "______________________________________________________"
|
||||
write(*, form) "rprec1", kind(n1), p1, precision(n1), r1, range(n1)
|
||||
write(*, form) "rprec2", kind(n2), p2, precision(n2), r1, range(n2)
|
||||
write(*, form) "rprec3", kind(n3), p2, precision(n3), r2, range(n3)
|
||||
write(*,*)
|
||||
form = "(a7, i11, i25, i8)"
|
||||
write(*, form) "iprec1", kind(n4), r3, range(n4)
|
||||
write(*, form) "iprec2", kind(n5), r4, range(n5)
|
||||
write(*, form) "iprec3", kind(n6), r5, range(n6)
|
||||
write(*, form) "iprec4", kind(n7), r6, range(n7)
|
||||
|
||||
end program
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
type
|
||||
{$packEnum 4}
|
||||
enum = (x, y, z);
|
||||
25
Task/Variable-size-Set/Go/variable-size-set.go
Normal file
25
Task/Variable-size-Set/Go/variable-size-set.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func main() {
|
||||
i := 5 // default type is int
|
||||
r := '5' // default type is rune (which is int32)
|
||||
f := 5. // default type is float64
|
||||
c := 5i // default type is complex128
|
||||
fmt.Println("i:", unsafe.Sizeof(i), "bytes")
|
||||
fmt.Println("r:", unsafe.Sizeof(r), "bytes")
|
||||
fmt.Println("f:", unsafe.Sizeof(f), "bytes")
|
||||
fmt.Println("c:", unsafe.Sizeof(c), "bytes")
|
||||
iMin := int8(5)
|
||||
rMin := byte('5')
|
||||
fMin := float32(5.)
|
||||
cMin := complex64(5i)
|
||||
fmt.Println("iMin:", unsafe.Sizeof(iMin), "bytes")
|
||||
fmt.Println("rMin:", unsafe.Sizeof(rMin), "bytes")
|
||||
fmt.Println("fMin:", unsafe.Sizeof(fMin), "bytes")
|
||||
fmt.Println("cMin:", unsafe.Sizeof(cMin), "bytes")
|
||||
}
|
||||
16
Task/Variable-size-Set/Haskell/variable-size-set.hs
Normal file
16
Task/Variable-size-Set/Haskell/variable-size-set.hs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import Data.Int
|
||||
import Foreign.Storable
|
||||
|
||||
task name value = putStrLn $ name ++ ": " ++ show (sizeOf value) ++ " byte(s)"
|
||||
|
||||
main = do
|
||||
let i8 = 0::Int8
|
||||
let i16 = 0::Int16
|
||||
let i32 = 0::Int32
|
||||
let i64 = 0::Int64
|
||||
let int = 0::Int
|
||||
task "Int8" i8
|
||||
task "Int16" i16
|
||||
task "Int32" i32
|
||||
task "Int64" i64
|
||||
task "Int" int
|
||||
7
Task/Variable-size-Set/IS-BASIC/variable-size-set.basic
Normal file
7
Task/Variable-size-Set/IS-BASIC/variable-size-set.basic
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
100 DIM A(10)
|
||||
110 NUMERIC ARRAY(1 TO 100)
|
||||
120 NUMERIC MATRIX(1 TO 10,1 TO 10)
|
||||
130 NUMERIC NR,X,Y
|
||||
140 STRING NAME$(1 TO 100)*24
|
||||
150 STRING LINE$*254
|
||||
160 STRING CHAR$*1
|
||||
1
Task/Variable-size-Set/Icon/variable-size-set.icon
Normal file
1
Task/Variable-size-Set/Icon/variable-size-set.icon
Normal file
|
|
@ -0,0 +1 @@
|
|||
L := list(10) # 10 element list
|
||||
1
Task/Variable-size-Set/J/variable-size-set.j
Normal file
1
Task/Variable-size-Set/J/variable-size-set.j
Normal file
|
|
@ -0,0 +1 @@
|
|||
v=: ''
|
||||
10
Task/Variable-size-Set/Julia/variable-size-set.julia
Normal file
10
Task/Variable-size-Set/Julia/variable-size-set.julia
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
types = [Bool, Char, Int8, UInt8, Int16, UInt16, Int32, UInt32, Int64, UInt64]
|
||||
|
||||
for t in types
|
||||
println("For type ", lpad(t,6), " size is $(sizeof(t)) 8-bit bytes, or ",
|
||||
lpad(string(8*sizeof(t)), 2), " bits.")
|
||||
end
|
||||
|
||||
primitive type MyInt24 24 end
|
||||
|
||||
println("\nFor the 24-bit user defined type MyInt24, size is ", sizeof(MyInt24), " bytes.")
|
||||
11
Task/Variable-size-Set/Kotlin/variable-size-set.kotlin
Normal file
11
Task/Variable-size-Set/Kotlin/variable-size-set.kotlin
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// version 1.0.6
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
/* ranges for variables of the primitive numeric types */
|
||||
println("A Byte variable has a range of : ${Byte.MIN_VALUE} to ${Byte.MAX_VALUE}")
|
||||
println("A Short variable has a range of : ${Short.MIN_VALUE} to ${Short.MAX_VALUE}")
|
||||
println("An Int variable has a range of : ${Int.MIN_VALUE} to ${Int.MAX_VALUE}")
|
||||
println("A Long variable has a range of : ${Long.MIN_VALUE} to ${Long.MAX_VALUE}")
|
||||
println("A Float variable has a range of : ${Float.MIN_VALUE} to ${Float.MAX_VALUE}")
|
||||
println("A Double variable has a range of : ${Double.MIN_VALUE} to ${Double.MAX_VALUE}")
|
||||
}
|
||||
1
Task/Variable-size-Set/Modula-3/variable-size-set.mod3
Normal file
1
Task/Variable-size-Set/Modula-3/variable-size-set.mod3
Normal file
|
|
@ -0,0 +1 @@
|
|||
TYPE UByte = BITS 8 FOR [0..255];
|
||||
3
Task/Variable-size-Set/Nim/variable-size-set-1.nim
Normal file
3
Task/Variable-size-Set/Nim/variable-size-set-1.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
type
|
||||
MyBitfield = object
|
||||
flag {.bitsize:1.}: cuint
|
||||
3
Task/Variable-size-Set/Nim/variable-size-set-2.nim
Normal file
3
Task/Variable-size-Set/Nim/variable-size-set-2.nim
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
struct mybitfield {
|
||||
unsigned int flag:1;
|
||||
};
|
||||
|
|
@ -0,0 +1 @@
|
|||
default(precision, 1000)
|
||||
|
|
@ -0,0 +1 @@
|
|||
\p 1000
|
||||
16
Task/Variable-size-Set/PL-I/variable-size-set.pli
Normal file
16
Task/Variable-size-Set/PL-I/variable-size-set.pli
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
declare i fixed binary (7), /* occupies 1 byte */
|
||||
j fixed binary (15), /* occupies 2 bytes */
|
||||
k fixed binary (31), /* occupies 4 bytes */
|
||||
l fixed binary (63); /* occupies 8 bytes */
|
||||
|
||||
declare d fixed decimal (1), /* occupies 1 byte */
|
||||
e fixed decimal (3), /* occupies 2 bytes */
|
||||
/* an so on ... */
|
||||
f fixed decimal (15); /* occupies 8 bytes */
|
||||
|
||||
declare b(16) bit (1) unaligned; /* occupies 2 bytes */
|
||||
declare c(16) bit (1) aligned; /* occupies 16 bytes */
|
||||
|
||||
declare x float decimal (6), /* occupies 4 bytes */
|
||||
y float decimal (16), /* occupies 8 bytes */
|
||||
z float decimal (33); /* occupies 16 bytes */
|
||||
2
Task/Variable-size-Set/Pascal/variable-size-set.pas
Normal file
2
Task/Variable-size-Set/Pascal/variable-size-set.pas
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
type
|
||||
correctInteger = integer attribute (size = 42);
|
||||
8
Task/Variable-size-Set/Phix/variable-size-set.phix
Normal file
8
Task/Variable-size-Set/Phix/variable-size-set.phix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(phixonline)-->
|
||||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
|
||||
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"1.0.0"</span><span style="color: #0000FF;">)</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;">mpfr</span> <span style="color: #000000;">pi</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">mpfr_init</span><span style="color: #0000FF;">(</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">121</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- 120 dp, +1 for the "3."</span>
|
||||
<span style="color: #7060A8;">mpfr_const_pi</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pi</span><span style="color: #0000FF;">)</span>
|
||||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"PI with 120 decimals: %s\n\n"</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">mpfr_get_fixed</span><span style="color: #0000FF;">(</span><span style="color: #000000;">pi</span><span style="color: #0000FF;">,</span><span style="color: #000000;">120</span><span style="color: #0000FF;">))</span>
|
||||
<!--
|
||||
40
Task/Variable-size-Set/PureBasic/variable-size-set.basic
Normal file
40
Task/Variable-size-Set/PureBasic/variable-size-set.basic
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
EnableExplicit
|
||||
|
||||
Structure AllTypes
|
||||
b.b
|
||||
a.a
|
||||
w.w
|
||||
u.u
|
||||
c.c ; character type : 1 byte on x86, 2 bytes on x64
|
||||
l.l
|
||||
i.i ; integer type : 4 bytes on x86, 8 bytes on x64
|
||||
q.q
|
||||
f.f
|
||||
d.d
|
||||
s.s ; pointer to string on heap : pointer size same as integer
|
||||
z.s{2} ; fixed length string of 2 characters, stored inline
|
||||
EndStructure
|
||||
|
||||
If OpenConsole()
|
||||
Define at.AllTypes
|
||||
PrintN("Size of types in bytes (x64)")
|
||||
PrintN("")
|
||||
PrintN("byte = " + SizeOf(at\b))
|
||||
PrintN("ascii = " + SizeOf(at\a))
|
||||
PrintN("word = " + SizeOf(at\w))
|
||||
PrintN("unicode = " + SizeOf(at\u))
|
||||
PrintN("character = " + SizeOf(at\c))
|
||||
PrintN("long = " + SizeOf(at\l))
|
||||
PrintN("integer = " + SizeOf(at\i))
|
||||
PrintN("quod = " + SizeOf(at\q))
|
||||
PrintN("float = " + SizeOf(at\f))
|
||||
PrintN("double = " + SizeOf(at\d))
|
||||
PrintN("string = " + SizeOf(at\s))
|
||||
PrintN("string{2} = " + SizeOf(at\z))
|
||||
PrintN("---------------")
|
||||
PrintN("AllTypes = " + SizeOf(at))
|
||||
PrintN("")
|
||||
PrintN("Press any key to close the console")
|
||||
Repeat: Delay(10) : Until Inkey() <> ""
|
||||
CloseConsole()
|
||||
EndIf
|
||||
11
Task/Variable-size-Set/REXX/variable-size-set.rexx
Normal file
11
Task/Variable-size-Set/REXX/variable-size-set.rexx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
/*REXX program demonstrates on setting a variable (using a "minimum var size".*/
|
||||
numeric digits 100 /*default: 9 (decimal digs) for numbers*/
|
||||
|
||||
/*── 1 2 3 4 5 6 7──*/
|
||||
/*──1234567890123456789012345678901234567890123456789012345678901234567890──*/
|
||||
|
||||
z = 12345678901111111112222222222333333333344444444445555555555.66
|
||||
n =-12345678901111111112222222222333333333344444444445555555555.66
|
||||
|
||||
/* [↑] these #'s are stored as coded. */
|
||||
/*stick a fork in it, we're all done. */
|
||||
7
Task/Variable-size-Set/Scala/variable-size-set.scala
Normal file
7
Task/Variable-size-Set/Scala/variable-size-set.scala
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
/* Ranges for variables of the primitive numeric types */
|
||||
println(s"A Byte variable has a range of : ${Byte.MinValue} to ${Byte.MaxValue}")
|
||||
println(s"A Short variable has a range of : ${Short.MinValue} to ${Short.MaxValue}")
|
||||
println(s"An Int variable has a range of : ${Int.MinValue} to ${Int.MaxValue}")
|
||||
println(s"A Long variable has a range of : ${Long.MinValue} to ${Long.MaxValue}")
|
||||
println(s"A Float variable has a range of : ${Float.MinValue} to ${Float.MaxValue}")
|
||||
println(s"A Double variable has a range of : ${Double.MinValue} to ${Double.MaxValue}")
|
||||
1
Task/Variable-size-Set/TXR/variable-size-set.txr
Normal file
1
Task/Variable-size-Set/TXR/variable-size-set.txr
Normal file
|
|
@ -0,0 +1 @@
|
|||
(make-buf 8 0 4096)
|
||||
9
Task/Variable-size-Set/Tcl/variable-size-set-1.tcl
Normal file
9
Task/Variable-size-Set/Tcl/variable-size-set-1.tcl
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
% proc format_trace {fmt _var el op} {upvar 1 $_var v; set v [format $fmt $v]}
|
||||
|
||||
% trace var foo w {format_trace %10s}
|
||||
% puts "/[set foo bar]/"
|
||||
/ bar/
|
||||
|
||||
% trace var grill w {format_trace %-10s}
|
||||
% puts "/[set grill bar]/"
|
||||
/bar /
|
||||
5
Task/Variable-size-Set/Tcl/variable-size-set-2.tcl
Normal file
5
Task/Variable-size-Set/Tcl/variable-size-set-2.tcl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
% proc range_trace {n _var el op} {upvar 1 $_var v; set v [string range $v 0 [incr n -1]]}
|
||||
|
||||
% trace var baz w {range_trace 2}
|
||||
% set baz Frankfurt
|
||||
Fr
|
||||
11
Task/Variable-size-Set/Ursala/variable-size-set.ursala
Normal file
11
Task/Variable-size-Set/Ursala/variable-size-set.ursala
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
p = mpfr..pi 200 # 200 bits of precision
|
||||
|
||||
x = mpfr..grow(1.0E+0,1000) # 160 default precision, grown to 1160
|
||||
|
||||
y = mpfr..shrink(1.0+0,40) # 160 default shrunk to 120
|
||||
|
||||
z = mpfr..add(p,y) # inherits 200 bits of precision
|
||||
|
||||
a = # 180 bits (not the default 160) because of more digits in the constant
|
||||
|
||||
1.00000000000000000000000000000000000000000000000000000E0
|
||||
16
Task/Variable-size-Set/V-(Vlang)/variable-size-set.v
Normal file
16
Task/Variable-size-Set/V-(Vlang)/variable-size-set.v
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
fn main() {
|
||||
b := true
|
||||
i := 5 // default type is i32
|
||||
r := '5'
|
||||
f := 5.0 // default type is float64
|
||||
println("b: ${sizeof(b)} bytes")
|
||||
println("i: ${sizeof(i)} bytes")
|
||||
println("r: ${sizeof(r)} bytes")
|
||||
println("f: ${sizeof(f)} bytes")
|
||||
i_min := i8(5)
|
||||
r_min := `5`
|
||||
f_min := f32(5.0)
|
||||
println("i_min: ${sizeof(i_min)} bytes")
|
||||
println("r_min: ${sizeof(r_min)} bytes")
|
||||
println("f_min: ${sizeof(f_min)} bytes")
|
||||
}
|
||||
8
Task/Variable-size-Set/Wren/variable-size-set.wren
Normal file
8
Task/Variable-size-Set/Wren/variable-size-set.wren
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
// create a list with 10 elements all initialized to zero
|
||||
var l = List.filled(10, 0)
|
||||
// give them different values and print them
|
||||
for (i in 0..9) l[i] = i
|
||||
System.print(l)
|
||||
// add another element to the list dynamically and print it again
|
||||
l.add(10)
|
||||
System.print(l)
|
||||
13
Task/Variable-size-Set/XPL0/variable-size-set.xpl0
Normal file
13
Task/Variable-size-Set/XPL0/variable-size-set.xpl0
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
string 0; \use zero-terminated strings
|
||||
char S,
|
||||
A(1), \sets up an array containing one byte
|
||||
B(0); \sets up an array containing no bytes
|
||||
int I;
|
||||
[S:= ""; \a zero-length (null) string
|
||||
A:= Reserve(1); \sets up a 1-byte array at runtime
|
||||
B:= Reserve(0); \sets up a 0-byte array at runtime
|
||||
I:= I ! 1<<3; \stores a single 1 bit into an integer
|
||||
I:= I & ~(1<<29); \stores a 0 bit into bit 29 of the integer
|
||||
IntOut(0, I>>3 & 1); \displays value of bit 3
|
||||
]
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
MyByte:
|
||||
byte 0 ;most assemblers will also accept DB or DFB
|
||||
MyWord:
|
||||
word 0 ;most assemblers will also accept DW or DFW
|
||||
MyDouble:
|
||||
dd 0
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
.rsset $C000 ;starting at $C000, the following labels represent sequential memory locations of length ".rs n"
|
||||
tempByte .rs 1
|
||||
tempWord .rs 2
|
||||
tempLong .rs 4
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
tempByte equ $C000
|
||||
tempWord equ $C001 ;high byte at $C002
|
||||
tempLong equ $C003 ;you have to track spacing yourself with this method
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
10 DIM a$(10): REM This array will be 10 characters long
|
||||
20 DIM b(10): REM this will hold a set of numbers. The fixed number of bytes per number is implementation specific
|
||||
30 LET c=5: REM this is a single numerical value of fixed size
|
||||
Loading…
Add table
Add a link
Reference in a new issue