Posted: Wed Jan 30, 2013 4:52 pm Post subject: New or Newbee to Bacom.
Hi, I just started up again with Nascom AVR after several years.
How is it possible to calculate with decimal number.
If C < 4 Then 'test expression
Print " >44 "
Elseif C > 20 Then 'test expression
Print " <102" 'this will be printed
Else
C = C - 4.0
C = C * 60.
C = C / 16.0
C = C + 44.0
Print C
Hello
Just look the help of bascom about the variable
To calculate with decimal number you have two solutions following your Ram place.
The idea is to give the good dimension to the variable.
but let me copy the help for you
Elementary Data Types
· Bit (1/8 byte). A bit can hold only the value 0 or 1. A group of 8 bits is called a byte.
· Byte (1 byte). Bytes are stores as unsigned 8-bit binary numbers ranging in value from 0 to 255.
· Integer (two bytes). Integers are stored as signed sixteen-bit binary numbers ranging in value from -32,768 to +32,767.
· Word (two bytes). Words are stored as unsigned sixteen-bit binary numbers ranging in value from 0 to 65535.
· Dword(fout bytes). Dwords are stored as unsigned 32-bit unsigned numbers ranging in value from 0 to 4294967295
· Long (four bytes). Longs are stored as signed 32-bit binary numbers ranging in value from -2147483648 to 2147483647.
· Single. Singles are stored as signed 32 bit binary numbers. Ranging in value from 1.5 x 10^–45 to 3.4 x 10^38
· Double. Doubles are stored as signed 64 bit binary numbers. Ranging in value from 5.0 x 10^–324 to 1.7 x 10^308
· String (up to 254 bytes). Strings are stored as bytes and are terminated with a 0-byte. A string dimensioned with a length of 10 bytes will occupy 11 bytes.
You understand that floating point are calculate with Single or double.
Dim J_single as single
J_single=4.0
then you must format your result with the format instruction :
Format or fusing
Again see the help and the samples to use it
Bon courage
JP
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum