Float speichern Kategorie: Programmierung (von JackFrost - 13.05.2005 0:03) | |
| |
Ich versuche eine float variable in ein 24c512 zu Speichern , mit dem veränderten eeprom.c2 function writeint(byte eepromaddr,int addr, float data) returns int { if write(eepromaddr,addr) { i2c.write(data shr 56); if ((addr+1) % Pagewrite)==0 {i2c.stop(); if not write(eepromaddr,addr+1) {lasterr=0x70001;return 0;} } i2c.write(data shr 48); if ((addr+2) % Pagewrite)==0 {i2c.stop(); if not write(eepromaddr,addr+2) {lasterr=0x70002;return 0;} } i2c.write(data shr 40); if ((addr+3) % Pagewrite)==0 {i2c.stop(); if not write(eepromaddr,addr+3) {lasterr=0x70003;return 0;} } i2c.write(data shr 32); if ((addr+4) % Pagewrite)==0 {i2c.stop(); if not write(eepromaddr,addr+4) {lasterr=0x70004;return 0;} } i2c.write(data shr 24); if ((addr+5) % Pagewrite)==0 {i2c.stop(); if not write(eepromaddr,addr+5) {lasterr=0x70005;return 0;} } i2c.write(data shr 16); if ((addr+6) % Pagewrite)==0 {i2c.stop(); if not write(eepromaddr,addr+6) {lasterr=0x70006;return 0;} } i2c.write(data shr 8); if ((addr+7) % Pagewrite)==0 {i2c.stop(); if not write(eepromaddr,addr+7) {lasterr=0x70007;return 0;} } i2c.write(data); i2c.stop(); return -1; } lasterr=0x70000; return 0; } { float data; if read(eepromaddr,addr) { data = i2c.read(); data = (((((((((((((data shl 8) or i2c.read()) shl 8) or i2c.read()) shl 8 ) or i2c.read()) shl 8) or i2c.read()) shl 8) or i2c.read()) shl 8) or i2c.read()) shl 8) or i2c.readlast(); i2c.stop(); return data; } lasterr=0x3000; return 0; } Leider wird aus 25.26 ein 25.00 nach dem lesen , kann man keine floats speichern ? Gruss JackFrost | |
Antwort schreiben Antworten: Re: Float speichern (von JackFrost - 13.05.2005 0:16) Re: Float speichern (von Cris - 13.05.2005 8:07) |