Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
objeck committed Feb 26, 2024
1 parent b69146b commit 650fc3d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
22 changes: 22 additions & 0 deletions core/compiler/lib_src/lang.obs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,17 @@ bundle System {
Number->IntToString(b->As(Int), 10, buffer);
return String->New(buffer, false);
}

#~
Returns an unsigned string representation of the value
@ignore-params
@return unsigned string representation of the value
~#
function : native : ToStringUnsigned(b : Byte) ~ String {
buffer := Char->New[16];
Number->IntToString(b->As(Int)->Abs(), 10, buffer);
return String->New(buffer, false);
}

#~
Prints values
Expand Down Expand Up @@ -1063,6 +1074,17 @@ bundle System {
string->Append(c);
return string;
}

#~
Returns an unsigned string representation of the value
@ignore-params
@return unsigned string representation of the value
~#
function : native : ToStringUnsigned(c : Char) ~ String {
string := String->New();
string->Append(c->As(Int)->Abs());
return string;
}

#~
Searches for all occurrences of the character array
Expand Down
2 changes: 1 addition & 1 deletion programs/tests/prgm286.obs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Counter from System.Concurrency.Thread {

method : public : Run(param:System.Base) ~ Nil {
count := 0;
while(count++ < @max) {
while(++count < @max + 1) {
"{$@name}: {$count}"->PrintLine();
};
}
Expand Down
6 changes: 3 additions & 3 deletions programs/tests/prgm287.obs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ class Test {
str := "𤭢";
System.IO.Standard->SetIntFormat(System.Number->Format->HEX);
u8str := str->ToByteArray();
each(i in u8str) {
c : Int := i;
c->Print();
each(b in u8str) {
i := b->As(Int)->Abs()->ToString();
i->ToInt()->Print();
" "->Print();
}
""->PrintLine();
Expand Down

0 comments on commit 650fc3d

Please sign in to comment.