Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mandelbrot example only zooms out and 0.9 < 1.0 == false #19766

Closed
mwmuni opened this issue Nov 4, 2023 · 1 comment · Fixed by #19773
Closed

Mandelbrot example only zooms out and 0.9 < 1.0 == false #19766

mwmuni opened this issue Nov 4, 2023 · 1 comment · Fixed by #19773
Labels
Bug This tag is applied to issues which reports bugs. Unit: Examples Bugs/feature requests, that are related to the examples.

Comments

@mwmuni
Copy link
Contributor

mwmuni commented Nov 4, 2023

Describe the bug

In the Mandelbrot example, attempting to scroll up or down results in only zooming out. The zoom function takes in the zoom_factor argument of type f64, however it does not behave normally.

link to Mandelbrot zoom function

println(zoom_factor) -> 0.9090909090909091
println(typeof(zoom_factor)) -> f64
zoom_factor < 1 -> false
zoom_factor < 1.0 -> false
f64(zoom_factor) < 1 -> true
f64(zoom_factor) < 1.0 -> true

Despite already being an f64, zoom_factor does not function correctly until cast as an f64 again.

Unfortunately, fixing this issue still results in the Mandlebrot only zooming out despite the state.scale increasing.

Reproduction Steps

fn (mut state AppState) zoom(zoom_factor f64) {

println(zoom_factor)
println(typeof(zoom_factor))
println(zoom_factor < 1)
println(zoom_factor < 1.0)
println(f64(zoom_factor) < 1)
println(f64(zoom_factor) < 1.0)

Expected Behavior

all evaluate to true

Current Behavior

evaluates to false unless recast as f64

Possible Solution

A git bisect identified the bad commit as: 055e113

I have made a pull request that comments out the lines causing the bug #19773

Additional Information/Context

Issue is not present using V 0.4.1, with the same mandelbrot.v file
0e2dc38

V version

0.4.2 fbefe68

Environment details (OS name and version, etc.)

V full version: V 0.4.2 fbefe68
OS: windows, Microsoft Windows 11 Pro v22621 64-bit
Processor: 16 cpus, 64bit, little endian,

getwd: C:\Users\matt_\Documents_scripts\repos\v\examples
vexe: C:\Users\matt_\Documents_scripts\repos\v\v.exe
vexe mtime: 2023-11-03 16:35:02

vroot: OK, value: C:\Users\matt_\Documents_scripts\repos\v
VMODULES: OK, value: C:\Users\matt_.vmodules
VTMP: OK, value: C:\Users\matt_\AppData\Local\Temp\v_0

Git version: git version 2.37.2.windows.2
Git vroot status: weekly.2023.44-30-gfbefe685-dirty (16 commit(s) behind V master)
.git/config present: true

CC version: Error: 'cc' is not recognized as an internal or external command,
operable program or batch file.

thirdparty/tcc status: thirdparty-windows-amd64 e90c2620

@mwmuni mwmuni added the Bug This tag is applied to issues which reports bugs. label Nov 4, 2023
@ArtemkaKun ArtemkaKun added the Unit: Examples Bugs/feature requests, that are related to the examples. label Nov 5, 2023
@spytheman
Copy link
Member

const zoom_factor = 1.1

fn abc(zoom_factor f64) {
    a := if zoom_factor < 1 { 1 } else { -1 }
    dump(a)
}

fn def(zfactor f64) {
    a := if zfactor < 1 { 1 } else { -1 }
    dump(a)
}

fn main() {
    abc(0.1)
    def(0.1)
}

This can be used as a simpler test for the regression.
Both functions should print the same value, but instead:

[f64_const_relations.v:5] a: -1
[f64_const_relations.v:10] a: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: Examples Bugs/feature requests, that are related to the examples.
Projects
None yet
3 participants