-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a94b5dc
commit a97c7a0
Showing
12 changed files
with
674 additions
and
350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
type T int|dyn|double; | ||
import "std/type/type-conversion"; | ||
|
||
f<int> main() { | ||
|
||
f<int> foo<T>(T t) { | ||
return 1; | ||
} | ||
|
||
/*import "std/text/format"; | ||
|
||
f<int> main() { | ||
foo(1); | ||
foo(1.0); | ||
foo("test"); | ||
} | ||
printf("toUpper: %c\n", toUpper('j')); | ||
printf("toUpper: %s\n", toUpper(String("This is a test."))); | ||
printf("toLower: %c\n", toLower('L')); | ||
printf("toLower: %s\n", toLower(String("This is a test."))); | ||
printf("capizalize: %s\n", capitalize(String("word"))); | ||
|
||
printf("formatThousandsDelimiter: %s\n", formatThousandsDelimiter(12345678)); | ||
printf("formatThousandsDelimiter: %s\n", formatThousandsDelimiter(12345678, '.')); | ||
|
||
printf("formatStorageSize: %s\n", formatStorageSize(1l)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1l, true)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234l)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234l, true)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567l)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567l, true)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567890l)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567890l, true)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567890123l)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567890123l, true)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567890123456l)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567890123456l, true)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567890123456789l)); | ||
printf("formatStorageSize: %s\n", formatStorageSize(1234567890123456789l, true)); | ||
}*/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,9 @@ | ||
public const int INT_SIZE = 32; | ||
public const int INT_MIN_VALUE = -2147483648; | ||
public const int INT_MAX_VALUE = 2147483647; | ||
public const unsigned int UINT_MIN_VALUE = 0; | ||
public const unsigned int UINT_MAX_VALUE = 4294967295u; | ||
|
||
// External functions | ||
ext f<unsigned int> snprintf(char*, unsigned long, string, int); | ||
|
||
// Converts an int to a double | ||
public f<double> toDouble(int input) { | ||
return 0.0 + input; | ||
} | ||
|
||
// Converts an int to a short | ||
public f<short> toShort(int input) { | ||
return cast<short>(input); | ||
} | ||
|
||
// Converts an int to a long | ||
public f<long> toLong(int input) { | ||
return cast<long>(input); | ||
} | ||
|
||
// Converts an int to a byte | ||
public f<byte> toByte(int input) { | ||
return cast<byte>(input); | ||
} | ||
|
||
// Converts an int to a char | ||
public f<char> toChar(int input) { | ||
return cast<char>(input); | ||
} | ||
|
||
// Converts an int to a string | ||
public f<String> toString(const int input) { | ||
const unsigned int length = snprintf(nil<char*>, 0l, "%d", input); | ||
result = String(length); | ||
snprintf(cast<char*>(result.getRaw()), length + 1l, "%d", input); | ||
} | ||
|
||
// Converts an int to a boolean | ||
public f<bool> toBool(int input) { | ||
return input >= 1; | ||
} | ||
|
||
// Check if the input is a power of two | ||
/** | ||
* Check if an int is a power of two | ||
* | ||
* @param input Input number | ||
* @return Is power of two | ||
*/ | ||
public f<bool> isPowerOfTwo(int input) { | ||
return (input & (input - 1)) == 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,9 @@ | ||
public const unsigned int SIZE = 64; | ||
public const long MIN_VALUE = -9223372036854775808l; | ||
public const long MAX_VALUE = 9223372036854775807l; | ||
public const unsigned long ULONG_MIN_VALUE = 0ul; | ||
public const unsigned long ULONG_MAX_VALUE = 18446744073709551615ul; | ||
|
||
// External functions | ||
ext f<unsigned int> snprintf(char*, unsigned long, string, long); | ||
|
||
// Converts a long to a double | ||
public f<double> toDouble(long input) { | ||
return 0.0 + input; | ||
} | ||
|
||
// Converts a long to an int | ||
public f<int> toInt(long input) { | ||
return cast<int>(input); | ||
} | ||
|
||
// Converts a long to a short | ||
public f<short> toShort(long input) { | ||
return cast<short>(input); | ||
} | ||
|
||
// Converts a long to a byte | ||
public f<byte> toByte(long input) { | ||
return cast<byte>(cast<int>(input)); | ||
} | ||
|
||
// Converts a long to a char | ||
public f<char> toChar(long input) { | ||
return cast<char>(input); | ||
} | ||
|
||
// Converts a long to a string | ||
public f<String> toString(long input) { | ||
const unsigned int length = snprintf(nil<char*>, 0l, "%ld", input); | ||
result = String(length); | ||
snprintf(cast<char*>(result.getRaw()), length + 1l, "%ld", input); | ||
} | ||
|
||
// Converts a long to a boolean | ||
public f<bool> toBool(long input) { | ||
return input >= 1; | ||
} | ||
|
||
// Check if the input is a power of two | ||
/** | ||
* Check if a long is a power of two | ||
* | ||
* @param input Input number | ||
* @return Is power of two | ||
*/ | ||
public f<bool> isPowerOfTwo(long input) { | ||
return (input & (input - 1l)) == 0l; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,9 @@ | ||
public const unsigned int SHORT_SIZE = 16; | ||
public const short SHORT_MIN_VALUE = -32768s; | ||
public const short SHORT_MAX_VALUE = 32767s; | ||
public const unsigned short USHORT_MIN_VALUE = 0s; | ||
public const unsigned short USHORT_MAX_VALUE = 65535us; | ||
|
||
// External functions | ||
ext f<unsigned int> snprintf(char*, unsigned long, string, short); | ||
|
||
// Converts a short to a double | ||
public f<double> toDouble(short input) { | ||
return 0.0 + input; | ||
} | ||
|
||
// Converts a short to an int | ||
public f<int> toInt(short input) { | ||
return cast<int>(input); | ||
} | ||
|
||
// Converts a short to a long | ||
public f<long> toLong(short input) { | ||
return cast<long>(input); | ||
} | ||
|
||
// Converts a short to a byte | ||
public f<byte> toByte(short input) { | ||
return cast<byte>(cast<int>(input)); | ||
} | ||
|
||
// Converts a short to a char | ||
public f<char> toChar(short input) { | ||
return cast<char>(input); | ||
} | ||
|
||
// Converts a short to a string | ||
public f<String> toString(short input) { | ||
const unsigned int length = snprintf(nil<char*>, 0l, "%hd", input); | ||
result = String(length); | ||
snprintf(cast<char*>(result.getRaw()), length + 1l, "%hd", input); | ||
} | ||
|
||
// Converts a short to a boolean | ||
public f<bool> toBool(short input) { | ||
return input >= 1; | ||
} | ||
|
||
// Check if the input is a power of two | ||
/** | ||
* Check if a short is a power of two | ||
* | ||
* @param input Input number | ||
* @return Is power of two | ||
*/ | ||
public f<bool> isPowerOfTwo(short input) { | ||
return (input & (input - 1s)) == 0s; | ||
} |
Oops, something went wrong.