mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Make rune a basic type and not an alias; Remove byte
This commit is contained in:
+9
-9
@@ -3,14 +3,14 @@
|
||||
// NOTE: This is only for floating point printing and nothing else
|
||||
|
||||
Decimal :: struct {
|
||||
digits: [384]byte, // big-endian digits
|
||||
digits: [384]u8, // big-endian digits
|
||||
count: int,
|
||||
decimal_point: int,
|
||||
neg, trunc: bool,
|
||||
}
|
||||
|
||||
decimal_to_string :: proc(buf: []byte, a: ^Decimal) -> string {
|
||||
digit_zero :: proc(buf: []byte) -> int {
|
||||
decimal_to_string :: proc(buf: []u8, a: ^Decimal) -> string {
|
||||
digit_zero :: proc(buf: []u8) -> int {
|
||||
for _, i in buf {
|
||||
buf[i] = '0';
|
||||
}
|
||||
@@ -59,12 +59,12 @@ trim :: proc(a: ^Decimal) {
|
||||
|
||||
|
||||
assign :: proc(a: ^Decimal, i: u64) {
|
||||
buf: [32]byte;
|
||||
buf: [32]u8;
|
||||
n := 0;
|
||||
for i > 0 {
|
||||
j := i/10;
|
||||
i -= 10*j;
|
||||
buf[n] = byte('0'+i);
|
||||
buf[n] = u8('0'+i);
|
||||
n++;
|
||||
i = j;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ shift_right :: proc(a: ^Decimal, k: uint) {
|
||||
c := uint(a.digits[r]);
|
||||
dig := n>>k;
|
||||
n &= mask;
|
||||
a.digits[w] = byte('0' + dig);
|
||||
a.digits[w] = u8('0' + dig);
|
||||
w++;
|
||||
n = n*10 + c - '0';
|
||||
}
|
||||
@@ -119,7 +119,7 @@ shift_right :: proc(a: ^Decimal, k: uint) {
|
||||
dig := n>>k;
|
||||
n &= mask;
|
||||
if w < len(a.digits) {
|
||||
a.digits[w] = byte('0' + dig);
|
||||
a.digits[w] = u8('0' + dig);
|
||||
w++;
|
||||
} else if dig > 0 {
|
||||
a.trunc = true;
|
||||
@@ -145,7 +145,7 @@ shift_left :: proc(a: ^Decimal, k: uint) {
|
||||
rem := n - 10*quo;
|
||||
w--;
|
||||
if w < len(a.digits) {
|
||||
a.digits[w] = byte('0' + rem);
|
||||
a.digits[w] = u8('0' + rem);
|
||||
} else if rem != 0 {
|
||||
a.trunc = true;
|
||||
}
|
||||
@@ -157,7 +157,7 @@ shift_left :: proc(a: ^Decimal, k: uint) {
|
||||
rem := n - 10*quo;
|
||||
w--;
|
||||
if 0 <= w && w < len(a.digits) {
|
||||
a.digits[w] = byte('0' + rem);
|
||||
a.digits[w] = u8('0' + rem);
|
||||
} else if rem != 0 {
|
||||
a.trunc = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user