Converting Float to Byte (123.456789 -> 123) need help from MikroBasic experts

Gast #1772782
Lesenswert?

Hey Guys

Having a problem to convert a Float to a byte. Used language is 
Mikrobasic Pro 2010.

Having this code:

Dim DataFloat as Float
Dim DataByte as Byte

DataFloat = 40.000
DataFloat = DataFloat * 6.375   // Scale 40 to 8bit
DataByte = DataFloat


Now Databyte should be 255. But it isn't.
How can I get the number befor the point?
DataFloat is generated from a calculation and can not be normal integer, 
or so.
#1772849
Lesenswert?

Hey Dude,

I wonder if there aren't any conversion functions like Cint()
as known to me from Visual Basic(used that some years ago).

Maybe you have to include a library or so, as i don't know MikroBasic.

A second chance would be accessing the float as a int, manually 
splitting it in mantissa and exponent and convert that in a homebrewn 
function. :D

minifloat

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren