Skip to content

[Bug]: Differnt results from equivalent math operations #1021

@NMMT76

Description

@NMMT76

Contact Details

No response

Compiler version

v.1.18.4

What happened?

First off, thank you for ZX Basic, without it I'd never have gotten so far on my "virtual expansion device" work ( Zero-EM )

Now onto the issue. As i was writing/testing some new webcam related functions in Zero-EM i came across a strange behavior, so i dug a bit deeper.

As you can see from the example, two different results for an equivalent operation. My guess is that the - sign at the beginning of the first one forces some sort of type expansion/coercion that doesn't happen on the second.

While its easy to work around it, by only using INTEGER's or "hinting" at the need for type expansion/coercion, its still "unexpected behavior".

DIM adjbri,adjcon,adjgam as UBYTE
adjbri=99
adjcon=99
dim brires,conres as INTEGER

CLS

brires=-100+adjbri
conres=-100+adjcon
Print at 0,0;"Bri:";str(brires);" Con:";str(conres)
brires=adjbri-100
conres=adjcon-100
Print at 1,0;"Bri:";str(brires);" Con:";str(conres)

Kind regards and many thanks for your work

Error and Warning messages

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions