Rounding Issue Causing Incorrect Latitude Value

31 views
Skip to first unread message

حسن حربي

unread,
Jan 30, 2026, 8:27:52 AM (3 days ago) Jan 30
to The Ring Programming Language

Dear All,

I would like to highlight an issue related to rounding that can lead to incorrect results.

For example, the latitude value is 30.8761. When the system rounds this value to two decimal places, it becomes 30.88. This rounding changes the actual value and can cause logical or validation mistakes in  calculations.

we need a proper way to control digits ,This will help ensure accuracy 

code example :

tolerance = 0.005
lat = 30.8761
see tolerance + nl
see lat + nl

-------------------------------------------------
the rustle :
0.01
30.88

Greetings,
Hassan Harby  

Bert Mariani

unread,
Jan 30, 2026, 9:13:53 AM (3 days ago) Jan 30
to حسن حربي, The Ring Programming Language
Hello ...

Unfortunately Floating Point is not precise and has rounding errors.

Back in the days of Main Frame computers .... The Hardware  had BCD Binary Coded Decimal  instructions and data format that was completely accurate.

Ring only supports Long Floating Point.

Regards
Bert Mariani 

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ring-lang/2db99b97-cc5b-40dd-a6ed-70bc3db42adcn%40googlegroups.com.

Mansour Ayouni

unread,
Jan 30, 2026, 9:15:24 AM (3 days ago) Jan 30
to Bert Mariani, حسن حربي, The Ring Programming Language
Hello Hassan,

May decimals(4) resolves your issue:
image.png
Best,
Mansour

Bert Mariani

unread,
Jan 30, 2026, 9:25:55 AM (3 days ago) Jan 30
to Mansour Ayouni, حسن حربي, The Ring Programming Language
Hello Hassan

+6
The Intel x86 architecture supports Binary-Coded Decimal (BCD)
, but this support is considered legacy and is not available in 64-bit mode (x86-64). The instructions were designed to assist in financial and commercial applications requiring precise decimal arithmetic, allowing for packed (two digits per byte) and unpacked (one digit per byte) BCD formats. 


Ilir Liburn

unread,
Jan 30, 2026, 9:31:46 AM (3 days ago) Jan 30
to The Ring Programming Language
Hello Hassan,

number is rounded because decimals is 2. Just us decimals(4) before calling print.

BTW, Ring2C supports long double type, result is still rounded

tolerance = 0.005
lat = 30.8761:long_double
see tolerance + nl
see lat + nl // prints 30.88

Greetings,
Ilir

حسن حربي

unread,
Jan 30, 2026, 11:21:48 AM (3 days ago) Jan 30
to The Ring Programming Language
Hello All,
Thanks for your support. after decimals function , i can control in digits.  

Greetings,
Hassan Harby
Reply all
Reply to author
Forward
0 new messages