Better documentation? Good idea!Warning? Hmm...Automatic casting? No!
This is a language for embedded software which runs on very limited hardware. 
On a Raspberry Pi, with at least 700MHz, 256MB ram and a processor which has 
hardware division support, right, automatic casting is the way to go.

In JAL however, you can use variables like byte*255, which is unusual, at least 
for microcontrollers. Automatic casting would have to deal with variables of 
such a size, which it can't. The one who writes a program needs to know what 
he's doing and tell the compiler what to do.
If you don't need speed, and have plenty of memory, just use dwords for 
everything you do. If you're using byte and word, the compiler should be 
allowed to assume you know what you're doing.

    Am Samstag, 30. März 2019, 19:39:55 MEZ hat Sunish Issac 
<[email protected]> Folgendes geschrieben:  
 
 This should go into the FAQ, as it's counter intuitive when compared to other 
languages, may be if the compiler is tweaked to give a warning.It would be even 
better if the compiler does the casting.
Sunish

On Sat, Mar 30, 2019 at 10:42 AM 'Oliver Seitz' via jallib 
<[email protected]> wrote:

 Hi all!
I thought this was solved when I read the word "casting" with reference to the 
documentation. This is the problem indeed.
A result is always the same size as the arguments, or the larger argument if 
they differ.
(word*word)=word
dword(word*word)= dword(word) 

you need to cast one (or both) of your input words to a dword to get the 
correct result:

var dword c= (dword(a)*b)/1000


Greets,Kiste


    Am Freitag, 29. März 2019, 19:07:38 MEZ hat Rian De Rous 
<[email protected]> Folgendes geschrieben:  
 
 
I have this code on a PIC18f27k42 and the output of this is 16 instead of 1000? 
5000*200 = 1 000 000, and that fits perfectly in a dword (four bytes). 
var word a= 200
var word b= 5000
var dword c= (a*b)/1000
print_dword_dec(lcd,c) 




I don't know if it's related to the compiler or to the jallib print_dword_dec() 
function. But the answer should be 1000 not  16. 

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/d/optout.
  

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/d/optout.
  

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/jallib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to