Jak w BASICu obsługiwać liczby zmiennoprzecinkowe i stałoprzecinkowe?

Re: Czy za pomoca BASIC'a...





Poprzedni Następny
Wiadomość
Spis treści
From: Janusz_K <Janusz_k.anty_at_nospam_um.bielsko.pl>
Subject: Re: Czy za pomoca BASIC'a...
Date: Mon, 01 Jul 2002 10:43:25 +0200


Kolejną
ciemną stroną są liczby zmiennoprzecinkowe. Oczywiście można pracować na
posiadanych bibliotekach zmiennoprzecinkowych ale w asemblerze jest to
niezwykle uciążliwe, dlatego najwyższym typem danych na jaki można się pokusić
to dwie dwubajtowe pary liczb reprezentujące jedną. Pierwsza para to licznik a
najstarszy bit znak licznika (+-32768 odpowiednik Integer) a druga para to
mianownik. W sumie jest to reprezentacja liczby rzeczywistej stałoprzecinkowej.
To w Bascomie nie musisz tak rzeźbić ;))
oto kawałek helpa"
'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.'


Na pocieszenie mogę powiedzieć, że proste kompilatory C też nie posiadają
zmiennoprzecinkowych.
A tu miła niespodzianka (oczywiście w Bascomie :) ):

Floating point
A new datatype is added to BASCOM : the single.
Single numbers conform to the IEEE binary floating point standard.

An eight-bit exponent and 24 bit mantissa are supported.
Using four bytes, the format is shown below:

31 30 ______23 22 ____________________________0
s exponent mantissa

The exponent is biased by 128. Above 128 are positive exponents and
below are negative. The sign bit is 0 for positive numbers and 1 for
negative. The mantissa is stored in hidden bit normalized format so
that 24 bits of precision can be obtained.


--
Pozdr.

Janusz
PS. Uwaga z adresu usuń '.ANTY'