It is currently Sun Apr 22, 2018 7:28 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Float/double division by 0 causes invalid memory access
PostPosted: Wed Apr 04, 2018 2:38 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Jan 21, 2011 8:25 am
Posts: 1018
Location: 'stralia!
Hi

Dividing a float constant by a float variable (or double) that happens to be 0 causes an invalid memory access.
If the left hand operand is a variable as well, the result is +Infinity as expected.

This seems to be related to the debugger as the correct result is shown in release mode.

Code:

Define x.d = 10
Define y.d = 0

y = x / y ; Works correctly.
MessageRequester("", StrF(y))


Define a.d = 0
a = 1.0 / a ; Invalid memory access.

MessageRequester("", StrF(a))


_________________
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds


Top
 Profile  
Reply with quote  
 Post subject: Re: Float/double division by 0 causes invalid memory access
PostPosted: Thu Apr 05, 2018 3:01 pm 
Offline
User
User
User avatar

Joined: Sat Sep 02, 2017 7:30 pm
Posts: 47
*** to Administrator: please delete this post reply ***


Last edited by PedroMartins on Fri Apr 06, 2018 2:20 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Float/double division by 0 causes invalid memory access
PostPosted: Thu Apr 05, 2018 4:01 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 30, 2013 4:39 pm
Posts: 382
I think it's because devision by 0. This is not possible.

Code:
Define a.d = 0

if a
a = 1.0 / a ; Invalid memory access.
endif

MessageRequester("", StrD(a))


Top
 Profile  
Reply with quote  
 Post subject: Re: Float/double division by 0 causes invalid memory access
PostPosted: Thu Apr 05, 2018 4:11 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 651
Shield wrote:
Hi

Dividing a float constant by a float variable (or double) that happens to be 0 causes an invalid memory access.
If the left hand operand is a variable as well, the result is +Infinity as expected.

This seems to be related to the debugger as the correct result is shown in release mode.


It's the same on Windows. I think, there is nothing to discuss. It's a bug in the debugger.

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Float/double division by 0 causes invalid memory access
PostPosted: Thu Apr 05, 2018 5:04 pm 
Offline
Addict
Addict
User avatar

Joined: Fri Jan 21, 2011 8:25 am
Posts: 1018
Location: 'stralia!
@PedroMartins:
This was just an oversight on my part. I tested with floats first and then doubles but forgot to switch StrF().
It's not working either way.

@Wolfram:
Division by zero is perfectly valid and well-defined with floating point data types,
so that's not the issue here either.

@Josh:
Yep.

_________________
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye