Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2022-01-24 02:09:34

M2m
Member
Registered: 2021-02-18
Posts: 27

GBDK2020 - print 32bit number

Can printf not print 32bit numbers ?

My code:

#include <gb/gb.h>
#include <stdio.h>
#include <stdint.h>

void main() {
  int32_t i = 45000;
//  printf("x:%ld \n", (int32_t)i); //<- %ld doesn't work
  printf("x:%d \n", (int32_t)i);
}


BGB output:

x: -20536


I'm trying to write a simple calculator....

Last edited by M2m (2022-01-25 05:32:42)

Offline

 

#2 2022-01-25 03:44:13

toxa
Member
Registered: 2020-02-13
Posts: 305

Re: GBDK2020 - print 32bit number

use ltoa()/ultoa()

Offline

 

#3 2022-01-25 07:38:12

M2m
Member
Registered: 2021-02-18
Posts: 27

Re: GBDK2020 - print 32bit number

toxa wrote:

use ltoa()/ultoa()

Ha ! That works !

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson