MCPcopy Create free account
hub / github.com/anjo76/angelscript / WriteFloat

Method WriteFloat

sdk/add_on/scriptfile/scriptfile.cpp:622–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

620}
621
622int CScriptFile::WriteFloat(float f)
623{
624 if( file == 0 )
625 return 0;
626
627 unsigned char buf[4];
628 union conv
629 {
630 asUINT val;
631 float fp;
632 } value;
633 value.fp = f;
634 if( mostSignificantByteFirst )
635 {
636 for( unsigned int n = 0; n < 4; n++ )
637 buf[n] = (value.val >> ((3-n)*4)) & 0xFF;
638 }
639 else
640 {
641 for( unsigned int n = 0; n < 4; n++ )
642 buf[n] = (value.val >> (n*8)) & 0xFF;
643 }
644
645 size_t r = fwrite(&buf, 4, 1, file);
646 return int(r);
647}
648
649int CScriptFile::WriteDouble(double d)
650{

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected