RIDDLE

17 views
Skip to first unread message

Hans van Veldhuizen

unread,
Feb 20, 2025, 3:11:25 PMFeb 20
to jallist
Another öld-mans-riddle:

What I used to do is no longer possible, what am I doing wrong?
--------------------------------------------------------------------
 var word SON
SON= (adc_read_low_res(0))*10
Does not give a word but a byte value
This is correct:
SON= adc_read_low_res(0)
SON = SON*10
----------------------------------------------------------------------------
var word Kwin
KWin = (Indata[1] -48)*1000
Does not give a word but a byte value
This is correct:
KWin = Indata[1] -48
Kwin = Kwin*1000

Rob CJ

unread,
Feb 21, 2025, 1:22:32 AMFeb 21
to jallist
Hi Hans,

That is because you multiply a return value of type byte with 10 and it stays a byte.

You should change the return of type byte to a word first before multiplying.

That is done as follows: SON = word(adc_read_low_res(0)) * 10

In your version that is corret you first assign the returned byte value to a word and then you multiply it with 10.

Kind regards,

Rob


Van: jal...@googlegroups.com <jal...@googlegroups.com> namens Hans van Veldhuizen <hanz...@zeelandnet.nl>
Verzonden: donderdag 20 februari 2025 21:11
Aan: jallist <jal...@googlegroups.com>
Onderwerp: [jallist] RIDDLE
 
--
You received this message because you are subscribed to the Google Groups "jallist" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jallist+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/jallist/84804838-08e6-4e29-bd12-a8f744f7d3d7n%40googlegroups.com.

Hans van Veldhuizen

unread,
Feb 21, 2025, 5:25:24 AMFeb 21
to jallist
Hi Rob,
What about the second example I gave?

Op vrijdag 21 februari 2025 om 07:22:32 UTC+1 schreef Rob CJ:

Rob CJ

unread,
Feb 21, 2025, 6:43:53 AMFeb 21
to jallist
Hi Hans,

Same thing. I assume Indata[1] is a byte so it should be: word(Indata[1] -48) * 1000

Kind regards,

Rob


Verzonden: vrijdag 21 februari 2025 11:25
Aan: jallist <jal...@googlegroups.com>
Onderwerp: Re: [jallist] RIDDLE
 

Hans van Veldhuizen

unread,
Feb 21, 2025, 10:55:16 AMFeb 21
to jallist
Hello Rob,
That is really strange. !! I realize now that I have forced myself to work with bytes all those years.. That is why I never had any problems with it. 
Learned something new
. A person is never too old to learn something.
greetings
Hans

Op vrijdag 21 februari 2025 om 12:43:53 UTC+1 schreef Rob CJ:
Reply all
Reply to author
Forward
0 new messages