I fixed it like this:

Code: Select all

```
IF LEN STR$ M>6 THEN LET M=0
```

Thanks,

Shaun.

Last night I had an issue with ZX BASIC in that I was getting an odd result when LET M=.25 and I took .25 away. The result was not zero. I don't remember exactly but the number returned was something like 1.141322E-10

I fixed it like this:

This might be how I had EightyOne set up. In what other circumstances could this happen?

Thanks,

Shaun.

I fixed it like this:

Code: Select all

```
IF LEN STR$ M>6 THEN LET M=0
```

Thanks,

Shaun.

If you calculating with floating point values these may loose precision over the time (during calculations).

You could use INT to round them. Be aware that INT only cuts the value, doesn't round up.

For two digits you could use something like this:
This should round correctly:

You could use INT to round them. Be aware that INT only cuts the value, doesn't round up.

For two digits you could use something like this:

Code: Select all

```
10 LET A=2/3
20 LET R=INT(A*100)/100
30 PRINT A,R
```

Code: Select all

```
10 LET A=2/3
20 LET R=INT(A*100+0.5)/100
30 PRINT A,R
```

So where I'm looping and decreasing a value (each loop is LET M=M-.25), I'm fixing with this:

This should therefore basically call the INT function every 4th loop and will hopefully will fix recursive rounding errors.

Regards,

Shaun.

Code: Select all

```
IF M=INT M THEN LET M=INT M
```

Regards,

Shaun.

- 1024MAK
**Posts:**1859**Joined:**Mon Sep 26, 2011 10:56 am**Location:**Looking forward to summer in Somerset, UK...

This problem exists on the ZX Spectrum BASIC as well.

The way that real numbers are handled internally is not always exactly the same. As these are floating point numbers, using the = or <> operators, you often get unwanted results.

In my programs I test for a small range of values using the greater than and less than operators.

*Mark*

The way that real numbers are handled internally is not always exactly the same. As these are floating point numbers, using the = or <> operators, you often get unwanted results.

In my programs I test for a small range of values using the greater than and less than operators.

"ZxBasic"..."editor"... from XavSnap? http://dskcenter.free.fr/zxtools

Ooops!

Yes, in "ZxBasic editor","ZxToken" and "Vb81 XuR" text input (loaded in the file explorer), the Visual basic give a corrupt value for numbers lower than ".5".

It's a Vb integer fault, due to an internal error!

If a text file is imported to "ZxBasic editor","ZxToken" or "Vb81 Xur" (same import codes used), just convert the number to a VAL"xxxx" function!

For all of values lower than .5 !

Example:

10 LET M=.2 >>> 10 LET M=VAL".2"

10 LET M=.123456789 >>> 10 LET M=VAL".123456789"

NOTE:

To save a file in a "ZxBasic editor" format, just type : SAVE"MYPROG.TXT"

The text file will be saved in text format (ASM hex/dec+BASIC) in the current work directory.

Ooops!

Yes, in "ZxBasic editor","ZxToken" and "Vb81 XuR" text input (loaded in the file explorer), the Visual basic give a corrupt value for numbers lower than ".5".

It's a Vb integer fault, due to an internal error!

If a text file is imported to "ZxBasic editor","ZxToken" or "Vb81 Xur" (same import codes used), just convert the number to a VAL"xxxx" function!

For all of values lower than .5 !

Example:

10 LET M=.2 >>> 10 LET M=VAL".2"

10 LET M=.123456789 >>> 10 LET M=VAL".123456789"

NOTE:

To save a file in a "ZxBasic editor" format, just type : SAVE"MYPROG.TXT"

The text file will be saved in text format (ASM hex/dec+BASIC) in the current work directory.

You could also just use integers and only display the amount of "money" on screen as possible turns/4.

Then you can decrease the integer and the calculation error will not occur.

Then you can decrease the integer and the calculation error will not occur.

For the game it could be useful to think of coins only which are transferred into a sum in display routine only.

This way you can adapt the game more easily when inflate is getting higher or let the user choose it's own currency and set an appropriate amount.

A quarter dollar is quite different to a quarter rubel (RUB) when people from Russia like to play.

This would be a nice add-on to choose the country first (maybe just from a list).

This way you can adapt the game more easily when inflate is getting higher or let the user choose it's own currency and set an appropriate amount.

A quarter dollar is quite different to a quarter rubel (RUB) when people from Russia like to play.

This would be a nice add-on to choose the country first (maybe just from a list).

And as for keeping the quarters on display on the ZX80:

LET M=INT (T/4)

LET Q=(T-M*4)*2+1

PRINT M;".";"00255075"(Q TO Q+1)

LET M=INT (T/4)

LET Q=(T-M*4)*2+1

PRINT M;".";"00255075"(Q TO Q+1)

This works....