Commit Graph

81 Commits (d5968086fe357aa5cf678327295677dba5102fc8)

Author SHA1 Message Date
Marc Tiehuis 353419f82d Default to strict IEEE floating point
Closes #1227.
2018-08-23 22:54:46 +12:00
Andrew Kelley 5a919dd82d Merge remote-tracking branch 'origin/master' into self-hosted-libc-hello-world 2018-07-23 14:32:13 -04:00
Andrew Kelley 99153ac0aa add std.math.big.Int.fitsInTwosComp
so that we can pass runtime-known values
2018-07-22 10:58:45 -04:00
Marc Tiehuis d53fae3551 Add big int fits function (#1279)
Returns whether the current value in an Int fits in the requested type.
2018-07-22 10:11:27 -04:00
Marc Tiehuis 07b6a3d335 Tighten Int.to bounds and add twos-complement bitcount 2018-07-22 17:47:57 +12:00
Andrew Kelley f5a67dba08 self-hosted: implicit cast comptime ints to other ints
we now have successful exit codes from main linking
against libc
2018-07-20 01:46:49 -04:00
Andrew Kelley 1d85b588ea self-hosted: progress on IR for supporting libc hello world
* add c int types
 * some more ir stubs
2018-07-19 00:08:47 -04:00
Andrew Kelley e9a03cccf3 all integer sizes are available as primitives
* fix wrong implicit cast for `@IntType` bit_count parameter.
 * fix incorrect docs for `@IntType` bit_count parameter.

closes #1242
closes #745
closes #1240
2018-07-16 10:53:15 -04:00
Ben Noordhuis 30cfc0ab2c test std.math f16 sqrt support
refs #1122
2018-06-30 01:58:17 +02:00
Ben Noordhuis be36179064 add std.math f16 signbit support
refs #1122
2018-06-30 01:58:17 +02:00
Ben Noordhuis ca444e6191 add std.math f16 copysign support
refs #1122
2018-06-30 01:58:17 +02:00
Ben Noordhuis d293f1a0ed add std.math f16 floor support
refs #1122
2018-06-30 01:58:17 +02:00
Ben Noordhuis 1abc925292 add std.math f16 fabs support
refs #1122
2018-06-30 01:58:17 +02:00
Ben Noordhuis f36b095b5f add std.math f16 isnormal support
refs #1122
2018-06-30 01:58:17 +02:00
Ben Noordhuis 30b75ae353 add std.math f16 isfinite support
refs #1122
2018-06-30 01:58:17 +02:00
Ben Noordhuis a36d7b6131 add std.math f16 inf support
refs #1122
2018-06-30 01:58:17 +02:00
Ben Noordhuis 27b02413dc add std.math f16 nan support
refs #1122
2018-06-30 01:58:17 +02:00
Ben Noordhuis 61df5bc142 add std.math f16 constants
refs #1122
2018-06-30 01:58:17 +02:00
Marc Tiehuis f50c0c664f Add float repr bit extraction functions 2018-06-21 01:45:12 -04:00
Andrew Kelley c7804277bf `@floatToInt` now has safety-checked undefined behavior
when the integer part does not fit in the destination integer type

 * Also fix incorrect safety triggered for integer casting an
   `i32` to a `u7`. closes #1138
 * adds compiler-rt function: `__floatuntidf`
2018-06-19 16:06:10 -04:00
Andrew Kelley 4210f1f6a0 remove bool to int syntax. add @boolToInt
add missing docs

See #1061
2018-06-18 03:07:16 -04:00
Andrew Kelley 7912061226 remove integer and float casting syntax
* add `@intCast`
 * add `@floatCast`
 * add `@floatToInt`
 * add `@intToFloat`

See #1061
2018-06-17 02:57:07 -04:00
Andrew Kelley 06a26f0965 std.Complex: use better arg passing convention and fix a TODO 2018-06-16 21:32:53 -04:00
Andrew Kelley e311cd562b don't automatically take pointer when passing by non-copying value
this commit does not have all tests passing
2018-06-16 19:37:00 -04:00
Andrew Kelley 65d04cbeb4 std.DynLib: open the fd with CLOEXEC 2018-06-16 17:27:45 -04:00
Andrew Kelley 48de57d824 add basic std lib code for loading dynamic libraries
this is going to only work for very basic libraries;
I plan to slowly add more features over time to support more
complicated libraries
2018-06-16 17:01:23 -04:00
Marc Tiehuis dc8bda7e02 Add arbitrary-precision integer to std
A few notes on the implementation:

 - Any unsigned power of two integer type less than 64 bits in size is supported
 as a Limb type.
 - The algorithms used are kept simple for the moment. More complicated
 algorithms are generally only more useful as integer sizes increase a
 lot and I don't expect our current usage to be used for this purpose
 just yet.
 - All branches (practically) have been covered by tests.

See 986a2b3243/bench
for rough performance comparison numbers.

Closes #364.
2018-06-10 18:24:34 +12:00
Marc Tiehuis 212449bc23 Fix Log2Int type construction
The following case for example, would previously fail:

    const a = u24(1) << Log2Int(u24)(22);
2018-06-06 22:41:55 +12:00
Jimmi HC 02cb220faf Renamed "(int/float literal)" to "comptime_int/float" 2018-06-05 11:14:43 +02:00
Andrew Kelley fcbb7426fa use * for pointer type instead of &
See #770

To help automatically translate code, see the
zig-fmt-pointer-reform-2 branch.

This will convert all & into *. Due to the syntax
ambiguity (which is why we are making this change),
even address-of & will turn into *, so you'll have
to manually fix thes instances. You will be guaranteed
to get compile errors for them - expected 'type', found 'foo'
2018-05-31 17:28:07 -04:00
Andrew Kelley 0c16cd2d0e run zig fmt on the codebase
See #1003
2018-05-29 04:23:38 -04:00
Andrew Kelley b73307befb more std lib to postfix deref with zig fmt 2018-05-17 00:56:14 -04:00
Andrew Kelley 4787127cf6 partial conversion to post-fix pointer deref using zig fmt 2018-05-10 00:29:49 -04:00
Andrew Kelley 6928badd85 Merge branch 'master' into pointer-reform 2018-05-09 23:43:07 -04:00
Andrew Kelley 41e1cd185b std.SegmentedList implementation 2018-05-07 01:04:43 -04:00
Andrew Kelley a35b366eb6 [breaking] delete ptr deref prefix op
start using zig-fmt-pointer-reform branch build of zig fmt
to fix code to use the new syntax

all of test/cases/* are processed, but there are more left
to be done - all the std lib used by the behavior tests
2018-04-30 20:35:54 -04:00
Andrew Kelley 84391af7b8 convert NOTE to TODO so we catch it later
See #363

For Complex as a builtin type, see discussion in #949
2018-04-24 21:23:03 -04:00
Andrew Kelley 1d998d5dce clean up complex math tests 2018-04-24 21:14:12 -04:00
Marc Tiehuis d5e99cc05e Add initial complex-number support
- Library type instead of builtin
 - All C complex functions implemented

Partial WIP: Needs more tests for edge cases.
2018-04-24 19:18:31 +12:00
Andrew Kelley 859b10d8bf std.math.ln and std.math.exp use float strict mode
closes #920
2018-04-15 15:22:27 -04:00
Andrew Kelley b5459eb987 add @sqrt built-in function
See #767
2018-04-15 13:26:58 -04:00
Andrew Kelley 5b00dee0c2 std.math.cast handles signed integers 2018-03-27 15:20:07 -04:00
Marc Tiehuis 53588f4f12 Add missing pub specifier to atan2 2018-03-22 19:18:51 +13:00
Andrew Kelley 39d5f44863 *WI* error sets - basic support working 2018-02-02 14:26:14 -05:00
Andrew Kelley 5f518dbeb9 *WIP* error sets converting std lib 2018-01-31 22:48:40 -05:00
Andrew Kelley 3671582c15 syntax: functions require return type. remove `->`
The purpose of this is:

 * Only one way to do things
 * Changing a function with void return type to return a possible
   error becomes a 1 character change, subtly encouraging
   people to use errors.

See #632

Here are some imperfect sed commands for performing this update:

remove arrow:

```
sed -i 's/\(\bfn\b.*\)-> /\1/g' $(find . -name "*.zig")
```

add void:

```
sed -i 's/\(\bfn\b.*\))\s*{/\1) void {/g' $(find ../ -name "*.zig")
```

Some cleanup may be necessary, but this should do the bulk of the work.
2018-01-25 04:10:11 -05:00
Andrew Kelley e5bc5873d7 rename "debug safety" to "runtime safety"
closes #437
2018-01-25 01:46:12 -05:00
Andrew Kelley 793f031c4c remove 32-bit windows from supported targets list
we still want to support it, but there are too many bugs
to claim that we support it right now.

See #537
2018-01-14 15:17:07 -05:00
Marc Tiehuis 304f6f1d01 Add integer rotation functions 2018-01-13 13:23:12 +13:00
Marc Tiehuis 24cd99160c Add hw sqrt for x86_64 2018-01-10 19:53:36 +13:00