Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Windows Tipps & SecurityGrafikkarte vor Überhitzung schützen: So geht’s(25.09.2026 um 08:00 Uhr)
••••••••••
Intelligence View
⚡ tsecurity.de Intelligence

Recreating Math.floor without the Math object? Here is my manual approach.

Ever tried to solve a problem while someone tied your hands behind your back? I recently took on a challenge to rebuild JavaScript's rounding methods without using any of the built in Math functions, no bitwise operators, and not even the…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Ever tried to solve a problem while someone tied your hands behind your back? I recently took on a challenge to rebuild JavaScript's rounding methods without using any of the built in Math functions, no bitwise operators, and not even the % operator.It sounds easy until you realize how many shortcuts we take for granted.



The Logic:

Finding the Floor, the biggest hurdle was performance. If you just loop 1 by 1 from zero, you'll crash the browser on large numbers. I decided to use a "fast-forward" while loop to jump by 100,000 at a time before using a for loop to find the exact integer.Here is the full implementation I came up with:




function floor(num) {
if (num >= 0) {
let i = 0
while(num > i+100000){
i = i+100000
}
for (i; ; i++) {
if (i + 1 > num) return i
}
} else {
for (let i = 0; ; i--) {
if (i <= num) return i
}
}
}

function ceil(num) {
let f = floor(num)
return f === num ? num : f + 1
}

function trunc(num) {
return num >= 0 ? floor(num) : ceil(num)
}

function round(num) {
if (num >= 0) {
return num - floor(num) >= 0.5 ? ceil(num) : floor(num)
} else {
return num - floor(num) >= 0.5 ? ceil(num) : floor(num)
}
}






Breakdown of the approach:



The "Big Jump":

In the floor function, I used while(num > i+100000) to skip through huge ranges. This keeps the execution time low even for values in the millions.



*Infinite Loops for recision: *

I used for(i; ; i++) without a middle condition. Since I know I’ll eventually hit a number larger than num, the if statement handles the return and breaks the loop safely.



Reusability:

Once floor was solid, ceil and trunc became easy extensions. They just lean on the core logic of finding that base integer.



Why do this?

It’s easy to call Math.round() and move on. But building it manually makes you think about how numbers are actually stored and compared. It's a great exercise in control flow and manual optimization.How would you have handled the jump logic? Would you go bigger than 10,000? Comment below! 👇






javascript #coding #webdev #algorithms

1. Sofort-Triage & Abwehrmaßnahmen

SOC Incident Playbook: Vulnerability Remediation & Verification
Syntax validiert (0 Fehler)
title: Detect Exploitation - Recreating Math.floor without the Math object? Here is my manual approach.
id: ba7e659c-e73b-4ec6-977e-1711ba02bfe7
status: experimental
description: Automatisch generierte SIEM-Erkennungsregel basierend auf CTI Intelligence
references:
  - https://tsecurity.de/
author: iShareStuff CTI Automated Detection Engine
date: 2026-09-25
logsource:
  category: network_connection
  product: any
detection:
  selection:
      CommandLine|contains:
        - 'exploit'
  condition: selection
falsepositives:
  - Legitime administrative Zugriffe oder Penetrationstests
level: high
tags:
  - attack.initial_access
Syntax validiert (0 Fehler)
rule CTI_Threat_Indicator {
    meta:
        author = "iShareStuff CTI Automated Detection Engine"
        date = "2026-09-25"
        description = "YARA Signature for "
    strings:
        $str = "Recreating Math.floor without " ascii wide
    condition:
        any of them
}
Syntax validiert (0 Fehler)
index=security sourcetype IN ("cisco:asa", "pan:traffic", "zeek_conn", "suricata", "WinEventLog:Security")
("Recreating Mathfloor without the Math ob")
| stats count earliest(_time) as first_seen latest(_time) as last_seen by src_ip, dest_ip, dest_host, signature
| eval first_seen=strftime(first_seen, "%Y-%m-%d %H:%M:%S"), last_seen=strftime(last_seen, "%Y-%m-%d %H:%M:%S")
| sort - count
Syntax validiert (0 Fehler)
message: "*Recreating Mathfloor without the Math ob*"
Syntax validiert (0 Fehler)
CommonSecurityLog
| where Message has "Recreating Mathfloor without the Math ob"
| summarize EventCount = count(), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by SourceIP, DestinationIP, DestinationPort, Activity
| extend DetectionRule = "iShareStuff-CTI-Compiled"
| sort by EventCount desc

2. Cyber Threat Intelligence & Forensik

🎯
MITRE ATT&CK Matrix Navigator 14 Taktiken
Reconnaissance
-
Resource Development
-
Initial Access
Execution
Persistence
-
Privilege Escalation
Defense Evasion
Credential Access
-
Discovery
-
Lateral Movement
-
Collection
-
Command and Control
Exfiltration
-
Impact
tsecurity.de Cognitive Threat RAG
Fokus-Vektor:

Kognitive Analyse für identifizierte Bedrohung: Erhöhte Bedrohungslage im Bereich Recreating Math.floor without the Math o.... Basierend auf 368k Vektor-Korrelationen werden sofortige Isolationsmaßnahmen für betroffene Endpunkte empfohlen.

🛡️ Angriffsfläche & Exposure

Netzwerk/Remote-Zugriff ohne Vorauthentifizierung möglich.

⚡ Empfohlene Sofortmaßnahmen
  • 1. Perimeter-Inspektion: Relevante Portfreigaben und exponierte Endpunkte unverzüglich scannen.
  • 2. Patch-Applikation: Hersteller-Hotfix einspielen oder betroffene Daemons in isolierte DMZ-Segmente überführen.
  • 3. Telemetrie & EDR-Alerts: Prozessaufrufe und Child-Processes auf anomale Shell-Spawns überwachen.
🔗 Semantisch verwandte Zero-Days MariaDB 11.7 VEC
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Recreating Math.floor without the Math object? Here is my manual approach.

Thematisch verwandte Begriffe: Recreating, Mathfloor, without, Math · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-97898 | Insecure Direct Object Reference / missing object-level authorization in…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag