Register | Login
Forum Index > Bugs and Fixes > error in return type of a function
Author Message
Pages: 1
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1803] error in return type of a function - posted: 2015-02-27 15:33:52
try this program

Code:
program PE32_CUI 'test application';

#set bits 32;

#include 'platform_def.zir';
#include 'console.zir';

function absf(single n) : single
{
   return (n >= 0) ? n : -n;
}

edx = absf(-200.0f);
print('Number: ', [single]edx ,'\r\n');

wait_key();
ExitProcess(0);


http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 932
Topics: 54

Location:
OverHertz Studio
[1804] - posted: 2015-02-27 15:39:40
Single is an FPU type and can only be used using FPU instructions...

In the future I may add some basic support for high level FPU and SSE usage.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1806] - posted: 2015-02-27 15:45:01
ok thanks Colin;



http://www.freewebs.com/ogremagic/index.htm
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1808] - posted: 2015-02-27 17:01:56
Emil_halim
To implement 'Abs' of float need to use 'fabs' FPU instruction. Something like:
Code:
single X;
fld @X; 
fabs;

Also to let you know it can be implemented by other way.
Find 'Abs' of float means that we just need to reset sign bit. According to http://en.wikipedia.org/wiki/Single-precision_floating-point_format#IEEE_754_single-precision_binary_floating-point_format:_binary32 it need to reset 31-th bit. Like this:
Code:
X &= 0x7FFFFFFF;


Also, Emil_halim, could you answer on my Private Message?
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1810] - posted: 2015-02-27 18:41:15
thank you very much

http://www.freewebs.com/ogremagic/index.htm
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 1 user(s) online. 0 member(s) and 1 guest(s)
Most users ever online was 999, May 11, 2018, 10:01 am.


Statistics:
Threads: 224 | Posts: 1847 | Members: 50 | Active Members: 50
Welcome to our newest member, NobodyAtWork
const Copyright = '2011-2021 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd