Thanks to visit codestin.com
Credit goes to github.com

Skip to content

floats and range #2

@data-man

Description

@data-man
const std = @import("std");
const it = @import("ziter.zig");

fn add(a: f32, b: f32) f32 { return a + b; }

test "f32, 0, 1, 0.1" {
	const result = it.range_ex(f32, 0, 1, 0.1)
	.call(it.fold, .{@as(f32, 0), add});
	std.debug.print("result = {}\n", .{result});
}

test "f32, 0, 1, 0.3" {
	const result = it.range_ex(f32, 0, 1, 0.3)
	.call(it.fold, .{@as(f32, 0), add});
	std.debug.print("result = {}\n", .{result});
}

test "f32, 0, 1, 0.1"... result = 4.5e+00 //correct
test "f32, 0, 1, 0.3"... result = 1.80000007e+00 //incorrect

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions